From 38cd45a3cdacf6d0bea95e3da41d7ae09da90fb7 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 5 Feb 2014 04:21:30 +0000 Subject: [PATCH] * internal.h: remove macros STR_NOCAPA and STR_NOCAPA_P(). * string.c (rb_str_resize): remove `STR_SET_NOEMBED(str)' because str_make_independent_expand() set NOEMBED flag. * string.c (rb_str_resize): remove `STR_NOCAPA_P(str)' check because `str' is independent (not shared). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ internal.h | 4 +--- string.c | 6 ++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 51be0a3cc2..f9d1e8ac5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Wed Feb 5 13:18:08 2014 Koichi Sasada + + * internal.h: remove macros STR_NOCAPA and STR_NOCAPA_P(). + + * string.c (rb_str_resize): remove `STR_SET_NOEMBED(str)' because + str_make_independent_expand() set NOEMBED flag. + + * string.c (rb_str_resize): remove `STR_NOCAPA_P(str)' check because + `str' is independent (not shared). + Wed Feb 5 12:54:25 2014 Koichi Sasada * string.c: refactoring, especially about string flags. diff --git a/internal.h b/internal.h index 3a6cb240b6..ddb59d64b3 100644 --- a/internal.h +++ b/internal.h @@ -717,10 +717,8 @@ VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc); #endif #define STR_NOEMBED FL_USER1 #define STR_SHARED FL_USER2 /* = ELTS_SHARED */ -#define STR_NOCAPA (STR_NOEMBED|ELTS_SHARED) #define STR_EMBED_P(str) (!FL_TEST((str), STR_NOEMBED)) -#define STR_SHARED_P(s) FL_ALL((s), STR_NOCAPA) -#define STR_NOCAPA_P(s) FL_ALL((s), STR_NOCAPA) +#define STR_SHARED_P(s) FL_ALL((s), STR_NOEMBED|ELTS_SHARED) #define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT) #define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN) diff --git a/string.c b/string.c index 16ba801c25..929ba516ff 100644 --- a/string.c +++ b/string.c @@ -1962,6 +1962,7 @@ rb_str_resize(VALUE str, long len) independent = str_independent(str); ENC_CODERANGE_CLEAR(str); slen = RSTRING_LEN(str); + if (len != slen) { const int termlen = TERM_LEN(str); if (STR_EMBED_P(str)) { @@ -1971,7 +1972,6 @@ rb_str_resize(VALUE str, long len) return str; } str_make_independent_expand(str, len - slen); - STR_SET_NOEMBED(str); } else if (len + termlen <= RSTRING_EMBED_LEN_MAX + 1) { char *ptr = STR_HEAP_PTR(str); @@ -1989,9 +1989,7 @@ rb_str_resize(VALUE str, long len) else if (slen < len || slen - len > 1024) { REALLOC_N(RSTRING(str)->as.heap.ptr, char, len + termlen); } - if (!STR_NOCAPA_P(str)) { - RSTRING(str)->as.heap.aux.capa = len; - } + RSTRING(str)->as.heap.aux.capa = len; RSTRING(str)->as.heap.len = len; TERM_FILL(RSTRING(str)->as.heap.ptr + len, termlen); /* sentinel */ }