From 8e75f9705fcd519390652dfebfef99ce3c6314a1 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 20 Apr 2009 22:09:30 +0000 Subject: [PATCH] * array.c (rb_ary_push): bypass rb_ary_store(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ array.c | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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; }