ruby-changes:4073
From: ko1@a...
Date: Thu, 21 Feb 2008 16:35:48 +0900 (JST)
Subject: [ruby-changes:4073] nobu - Ruby:r15563 (trunk): * array.c (rb_ary_unshift_m): expands enough for argc.
nobu 2008-02-21 16:35:29 +0900 (Thu, 21 Feb 2008)
New Revision: 15563
Modified files:
trunk/ChangeLog
trunk/array.c
Log:
* array.c (rb_ary_unshift_m): expands enough for argc. [ruby-dev:33880]
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/array.c?r1=15563&r2=15562&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15563&r2=15562&diff_format=u
Index: array.c
===================================================================
--- array.c (revision 15562)
+++ array.c (revision 15563)
@@ -368,7 +368,7 @@
idx += RARRAY_LEN(ary);
if (idx < 0) {
rb_raise(rb_eIndexError, "index %ld out of array",
- idx - RARRAY_LEN(ary));
+ idx - RARRAY_LEN(ary));
}
}
@@ -604,12 +604,12 @@
static VALUE
rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
{
- long len = RARRAY(ary)->len;
+ long len;
if (argc == 0) return ary;
rb_ary_modify(ary);
- if (RARRAY(ary)->aux.capa <= RARRAY_LEN(ary)+argc) {
- RESIZE_CAPA(ary, RARRAY(ary)->aux.capa + ARY_DEFAULT_SIZE);
+ if (RARRAY(ary)->aux.capa <= (len = RARRAY(ary)->len) + argc) {
+ RESIZE_CAPA(ary, len + argc + ARY_DEFAULT_SIZE);
}
/* sliding items */
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15562)
+++ ChangeLog (revision 15563)
@@ -1,3 +1,7 @@
+Thu Feb 21 16:35:26 2008 Nobuyoshi Nakada <nobu@r...>
+
+ * array.c (rb_ary_unshift_m): expands enough for argc. [ruby-dev:33880]
+
Thu Feb 21 14:49:40 2008 Nobuyoshi Nakada <nobu@r...>
* io.c (argf_set_encoding): uses current_file after check if next
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/