diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-06 17:16:58 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-06 17:16:58 +0000 |
commit | 0814c4ac643fcbb2d7f2d6c077fa1626a5e59b77 (patch) | |
tree | 7c831ae332ff0304fe3d086c5f235f04658ceeb2 /enumerator.c | |
parent | 7a31096255cd226d16c918fa859e3e4a654e64b9 (diff) |
* 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
Diffstat (limited to 'enumerator.c')
-rw-r--r-- | enumerator.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/enumerator.c b/enumerator.c index 0a51709ac1..9223979445 100644 --- a/enumerator.c +++ b/enumerator.c @@ -1741,6 +1741,11 @@ lazy_drop_while(VALUE obj) } 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) { return rb_funcall2(argv[0], id_yield, argc - 1, argv + 1); @@ -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 |