diff options
author | Peter Zhu <peter@peterzhu.ca> | 2022-03-07 09:35:24 -0500 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2022-03-07 09:37:49 -0500 |
commit | c445963575a8572f6b0baf7135093c128adab3b9 (patch) | |
tree | 65a2fc17aac8748c2453f1cdfd3f188a1f92434d /array.c | |
parent | 9cbebdcb74b98a012be72c8cc6b64099312eb432 (diff) |
Use rb_ary_unshare for shared array in rb_ary_replace
rb_ary_unshare will perform FL_UNSET_SHARED and
rb_ary_decrement_share.
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 8 |
1 files changed, 1 insertions, 7 deletions
@@ -4392,20 +4392,14 @@ rb_ary_replace(VALUE copy, VALUE orig) if (copy == orig) return copy; if (RARRAY_LEN(orig) <= RARRAY_EMBED_LEN_MAX) { - VALUE shared_root = 0; - if (ARY_OWNS_HEAP_P(copy)) { ary_heap_free(copy); } else if (ARY_SHARED_P(copy)) { - shared_root = ARY_SHARED_ROOT(copy); - FL_UNSET_SHARED(copy); + rb_ary_unshare(copy); } FL_SET_EMBED(copy); ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR_TRANSIENT(orig)); - if (shared_root) { - rb_ary_decrement_share(shared_root); - } ARY_SET_LEN(copy, RARRAY_LEN(orig)); } else { |