[前][次][番号順一覧][スレッド一覧]

ruby-changes:11602

From: matz <ko1@a...>
Date: Tue, 21 Apr 2009 07:09:46 +0900 (JST)
Subject: [ruby-changes:11602] Ruby:r23239 (trunk): * array.c (rb_ary_push): bypass rb_ary_store().

matz	2009-04-21 07:09:30 +0900 (Tue, 21 Apr 2009)

  New Revision: 23239

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23239

  Log:
    * array.c (rb_ary_push): bypass rb_ary_store().

  Modified files:
    trunk/ChangeLog
    trunk/array.c

Index: array.c
===================================================================
--- array.c	(revision 23238)
+++ array.c	(revision 23239)
@@ -697,7 +697,14 @@
 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;
 }
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23238)
+++ ChangeLog	(revision 23239)
@@ -1,3 +1,7 @@
+Tue Apr 21 07:07:45 2009  Yukihiro Matsumoto  <matz@r...>
+
+	* array.c (rb_ary_push): bypass rb_ary_store().
+
 Tue Apr 21 01:25:16 2009  Yukihiro Matsumoto  <matz@r...>
 
 	* bignum.c (bigsub_int): subtraction without making internal

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]