mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* enumerator.c: Support for lazy.cycle.size
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7a31096255
commit
0814c4ac64
4 changed files with 19 additions and 2 deletions
|
@ -1740,6 +1740,11 @@ lazy_drop_while(VALUE obj)
|
|||
Qnil, 0);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
lazy_cycle_size(VALUE lazy) {
|
||||
return enum_cycle_size(rb_ivar_get(lazy, id_receiver), rb_ivar_get(lazy, id_arguments));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
lazy_cycle_func(VALUE val, VALUE m, int argc, VALUE *argv)
|
||||
{
|
||||
|
@ -1764,7 +1769,7 @@ lazy_cycle(int argc, VALUE *argv, VALUE obj)
|
|||
return lazy_set_method(rb_block_call(rb_cLazy, id_new, len,
|
||||
RARRAY_PTR(args), lazy_cycle_func,
|
||||
args /* prevent from GC */),
|
||||
rb_ary_new4(argc, argv), 0);
|
||||
rb_ary_new4(argc, argv), lazy_cycle_size);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue