diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-06-05 02:33:01 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-06-05 02:33:01 +0000 |
commit | 4b33ed994b02c486aaf43a78e11e01fc6e936b10 (patch) | |
tree | e87ab144381b2da0ec2eaf0f5acfde2a2e04382e /string.c | |
parent | dfb79bf51e257c832ec7e431b861d78c39cde698 (diff) |
* string.c (str_new4): should share shared instance if it already
exists. [ruby-dev:23665]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -143,9 +143,9 @@ str_new4(klass, str) RSTRING(str2)->len = RSTRING(str)->len; RSTRING(str2)->ptr = RSTRING(str)->ptr; - if (FL_TEST(str, ELTS_SHARED) && !RSTRING(str)->aux.shared) { - /* ptr should be null_str */ + if (FL_TEST(str, ELTS_SHARED)) { FL_SET(str2, ELTS_SHARED); + RSTRING(str2)->aux.shared = RSTRING(str)->aux.shared; } else { FL_SET(str, ELTS_SHARED); @@ -165,7 +165,6 @@ rb_str_new4(orig) klass = rb_obj_class(orig); if (FL_TEST(orig, ELTS_SHARED) && (str = RSTRING(orig)->aux.shared) && klass == RBASIC(str)->klass) { long ofs; - str = RSTRING(orig)->aux.shared; ofs = RSTRING(str)->len - RSTRING(orig)->len; if (ofs > 0) { str = str_new3(klass, str); |