summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-09 15:11:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-09 15:11:01 +0000
commit82e937f511eb61b1726ffdc57f71c2a067e31974 (patch)
treec9f02ca6da3db7e1bd92a229d8d313eea59ea408 /array.c
parent42b298560b3ac5df01b139d6d4e9b91b0760c466 (diff)
* array.c (rb_ary_replace): use ptr and len of orig instead of
shared. fixed: [ruby-dev:30116] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/array.c b/array.c
index fae5fe016e..7f9925292a 100644
--- a/array.c
+++ b/array.c
@@ -2090,15 +2090,17 @@ rb_ary_replace(VALUE copy, VALUE orig)
VALUE shared;
VALUE *ptr;
- rb_ary_modify(copy);
- ary_iter_check(copy);
orig = to_ary(orig);
+ rb_ary_modify_check(copy);
+ ary_iter_check(copy);
if (copy == orig) return copy;
shared = ary_make_shared(orig);
- ptr = RARRAY(copy)->ptr;
+ if (!ARY_SHARED_P(copy)) {
+ ptr = RARRAY(copy)->ptr;
xfree(ptr);
- RARRAY(copy)->ptr = RARRAY(shared)->ptr;
- RARRAY(copy)->len = RARRAY(shared)->len;
+ }
+ RARRAY(copy)->ptr = RARRAY(orig)->ptr;
+ RARRAY(copy)->len = RARRAY(orig)->len;
RARRAY(copy)->aux.shared = shared;
FL_SET(copy, ELTS_SHARED);