diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | array.c | 9 |
2 files changed, 12 insertions, 1 deletions
@@ -1,3 +1,7 @@ +Tue Apr 21 07:07:45 2009 Yukihiro Matsumoto <matz@ruby-lang.org> + + * array.c (rb_ary_push): bypass rb_ary_store(). + Tue Apr 21 01:25:16 2009 Yukihiro Matsumoto <matz@ruby-lang.org> * bignum.c (bigsub_int): subtraction without making internal @@ -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; } |