ruby-changes:32748
From: ko1 <ko1@a...>
Date: Wed, 5 Feb 2014 13:21:35 +0900 (JST)
Subject: [ruby-changes:32748] ko1:r44827 (trunk): * internal.h: remove macros STR_NOCAPA and STR_NOCAPA_P().
ko1 2014-02-05 13:21:30 +0900 (Wed, 05 Feb 2014) New Revision: 44827 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44827 Log: * 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). Modified files: trunk/ChangeLog trunk/internal.h trunk/string.c Index: ChangeLog =================================================================== --- ChangeLog (revision 44826) +++ ChangeLog (revision 44827) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Feb 5 13:18:08 2014 Koichi Sasada <ko1@a...> + + * 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 <ko1@a...> * string.c: refactoring, especially about string flags. Index: string.c =================================================================== --- string.c (revision 44826) +++ string.c (revision 44827) @@ -1962,6 +1962,7 @@ rb_str_resize(VALUE str, long len) https://github.com/ruby/ruby/blob/trunk/string.c#L1962 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) https://github.com/ruby/ruby/blob/trunk/string.c#L1972 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) https://github.com/ruby/ruby/blob/trunk/string.c#L1989 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 */ } Index: internal.h =================================================================== --- internal.h (revision 44826) +++ internal.h (revision 44827) @@ -717,10 +717,8 @@ VALUE rb_external_str_with_enc(VALUE str https://github.com/ruby/ruby/blob/trunk/internal.h#L717 #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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/