зеркало из https://github.com/github/ruby.git
* enum.c (enum_each_with_index): make different arrays at each
iteration. [ruby-dev:32181] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ba80fd2bbf
Коммит
ec0187ef15
|
@ -1,3 +1,8 @@
|
|||
Wed Nov 7 15:07:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* enum.c (enum_each_with_index): make different arrays at each
|
||||
iteration. [ruby-dev:32181]
|
||||
|
||||
Tue Nov 7 05:17:24 2007 David Flanagan <davidflanagan@ruby-lang.org>
|
||||
|
||||
* eval.c: fix typo in invoke_method documentation
|
||||
|
|
17
enum.c
17
enum.c
|
@ -1293,15 +1293,9 @@ enum_member(VALUE obj, VALUE val)
|
|||
static VALUE
|
||||
each_with_index_i(VALUE val, VALUE memo)
|
||||
{
|
||||
long n;
|
||||
VALUE idx = RARRAY_PTR(memo)[1];
|
||||
long n = (*(VALUE *)memo)++;
|
||||
|
||||
RARRAY_PTR(memo)[0] = val;
|
||||
rb_yield(memo);
|
||||
n = NUM2LONG(idx);
|
||||
n++;
|
||||
RARRAY_PTR(memo)[1] = INT2NUM(n);
|
||||
return Qnil;
|
||||
return rb_yield(rb_ary_new3(2, val, INT2NUM(n)));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1322,12 +1316,12 @@ each_with_index_i(VALUE val, VALUE memo)
|
|||
static VALUE
|
||||
enum_each_with_index(int argc, VALUE *argv, VALUE obj)
|
||||
{
|
||||
VALUE memo;
|
||||
long memo;
|
||||
|
||||
RETURN_ENUMERATOR(obj, argc, argv);
|
||||
|
||||
memo = rb_ary_new3(2, Qnil, INT2FIX(0));
|
||||
rb_block_call(obj, id_each, argc, argv, each_with_index_i, memo);
|
||||
memo = 0;
|
||||
rb_block_call(obj, id_each, argc, argv, each_with_index_i, (VALUE)&memo);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -1534,7 +1528,6 @@ enum_drop_while(VALUE obj)
|
|||
return args[0];
|
||||
}
|
||||
|
||||
|
||||
static VALUE
|
||||
cycle_i(VALUE i, VALUE ary)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче