diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-21 07:35:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-21 07:35:29 +0000 |
commit | b356796f006af0c0836822e30e2c3b46dc8a8340 (patch) | |
tree | 5b6637c9c4f4a86a04c27a32977696c5be4ea5da | |
parent | ce0264b6f5dc41325abfd0b40abe6d8ad69976db (diff) | |
download | ruby-b356796f006af0c0836822e30e2c3b46dc8a8340.tar.gz |
* array.c (rb_ary_unshift_m): expands enough for argc. [ruby-dev:33880]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | array.c | 8 |
2 files changed, 8 insertions, 4 deletions
@@ -1,3 +1,7 @@ +Thu Feb 21 16:35:26 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * array.c (rb_ary_unshift_m): expands enough for argc. [ruby-dev:33880] + Thu Feb 21 14:49:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> * io.c (argf_set_encoding): uses current_file after check if next @@ -368,7 +368,7 @@ rb_ary_store(VALUE ary, long idx, VALUE val) 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 @@ rb_ary_shift_m(int argc, VALUE *argv, VALUE ary) 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 */ |