mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enum.c (enum_take): get rid of extraneous iteration.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
65370097cd
commit
51e0bcb72a
2 changed files with 7 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
Wed Aug 20 22:24:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* enum.c (enum_take): get rid of extraneous iteration.
|
||||
|
||||
Wed Aug 20 20:32:49 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (rb_io_open_with_args): use rb_open_file instead of rb_io_open.
|
||||
|
|
5
enum.c
5
enum.c
|
@ -1585,8 +1585,8 @@ enum_zip(int argc, VALUE *argv, VALUE obj)
|
|||
static VALUE
|
||||
take_i(VALUE i, VALUE *arg, int argc, VALUE *argv)
|
||||
{
|
||||
if (arg[1]-- == 0) rb_iter_break();
|
||||
rb_ary_push(arg[0], enum_values_pack(argc, argv));
|
||||
if (--arg[1] == 0) rb_iter_break();
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
@ -1611,8 +1611,9 @@ enum_take(VALUE obj, VALUE n)
|
|||
rb_raise(rb_eArgError, "attempt to take negative size");
|
||||
}
|
||||
|
||||
args[1] = len;
|
||||
if (len == 0) return rb_ary_new2(0);
|
||||
args[0] = rb_ary_new();
|
||||
args[1] = len;
|
||||
rb_block_call(obj, id_each, 0, 0, take_i, (VALUE)args);
|
||||
return args[0];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue