diff --git a/ChangeLog b/ChangeLog index cc046a99b0..2ea1857389 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Apr 21 07:07:45 2009 Yukihiro Matsumoto + + * array.c (rb_ary_push): bypass rb_ary_store(). + Tue Apr 21 01:25:16 2009 Yukihiro Matsumoto * bignum.c (bigsub_int): subtraction without making internal diff --git a/array.c b/array.c index 6da6ef9639..ac231a295a 100644 --- a/array.c +++ b/array.c @@ -697,7 +697,14 @@ ary_take_first_or_last(int argc, VALUE *argv, VALUE ary, enum ary_take_pos_flags VALUE rb_ary_push(VALUE ary, VALUE item) { - rb_ary_store(ary, RARRAY_LEN(ary), item); + long idx = RARRAY_LEN(ary); + + rb_ary_modify(ary); + if (idx >= ARY_CAPA(ary)) { + ary_double_capa(ary, idx); + } + RARRAY_PTR(ary)[idx] = item; + ARY_SET_LEN(ary, idx + 1); return ary; }