1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2008-02-21 07:35:29 +00:00
parent ce0264b6f5
commit b356796f00
2 changed files with 8 additions and 4 deletions

View file

@ -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

View file

@ -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 */