summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-05 02:33:01 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-05 02:33:01 +0000
commit44e45bf1dc6c3a8eeef415e0f171d64f816a439b (patch)
tree15c3b9d7707b83aa39c8bb796386cea44df0e601 /string.c
parentfcb315d1a2219ae4c2d772c414df4a29f1498434 (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/branches/ruby_1_8@6429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/string.c b/string.c
index 93ccae1..d8a4748 100644
--- a/string.c
+++ b/string.c
@@ -144,9 +144,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);
@@ -166,7 +166,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);