mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
84d8104ed6
commit
38cd45a3cd
3 changed files with 13 additions and 7 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Wed Feb 5 13:18:08 2014 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* 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@atdot.net>
|
||||
|
||||
* string.c: refactoring, especially about string flags.
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
6
string.c
6
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 */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue