Add ary_modify_check() to Array#unshift; ref #3737

This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-07-12 14:44:36 +09:00
parent e1de86134d
commit 059d707e3a
+1
View File
@@ -533,6 +533,7 @@ mrb_ary_unshift_m(mrb_state *mrb, mrb_value self)
if (ARY_SHARED_P(a)
&& a->aux.shared->refcnt == 1 /* shared only referenced from this array */
&& a->ptr - a->aux.shared->ptr >= len) /* there's room for unshifted item */ {
ary_modify_check(mrb, a);
a->ptr -= len;
}
else {