diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-29 16:30:10 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-29 16:30:10 +0000 |
commit | a2ed2d20cb69da4c0c0258f04d704a370cf02d84 (patch) | |
tree | 96f5a6522885f934ff29f89f32091168117e56f6 /string.c | |
parent | 3f7f77606acdd57ccbf82e46881a7b04d4b25a52 (diff) |
merge revision(s) 53724: [Backport #11946]
* string.c (str_new_frozen): if the given string is embeddedable
but not embedded, embed a new copied string. [Bug #11946]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1087,6 +1087,13 @@ str_new_frozen(VALUE klass, VALUE orig) return shared; } } + else if (RSTRING_LEN(orig)+TERM_LEN(orig) <= RSTRING_EMBED_LEN_MAX+1) { + str = str_alloc(klass); + STR_SET_EMBED(str); + memcpy(RSTRING_PTR(str), RSTRING_PTR(orig), RSTRING_LEN(orig)); + STR_SET_EMBED_LEN(str, RSTRING_LEN(orig)); + TERM_FILL(RSTRING_END(str), TERM_LEN(orig)); + } else { str = str_alloc(klass); STR_SET_NOEMBED(str); |