From 929faf7906a2f2ca7dbf5eda5670e666edddfa88 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 8 Jan 2008 09:50:01 +0000 Subject: * enum.c (enum_zip): honor length of the receiver, not the shortest length. [ruby-core:14738] * enum.c (enum_zip): returns array not enumerator for no block form. [ruby-core:14738] * enumerator.c (next_ii): do not ignore multiple values yielded. * array.c (rb_ary_zip): faster version without creating generators. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- enum.c | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'enum.c') diff --git a/enum.c b/enum.c index df3f103cab..faa688e11f 100644 --- a/enum.c +++ b/enum.c @@ -1346,6 +1346,18 @@ enum_each_with_index(int argc, VALUE *argv, VALUE obj) } +static VALUE +call_next(VALUE *v) +{ + return v[0] = rb_funcall(v[1], id_next, 0, 0); +} + +static VALUE +call_stop(VALUE *v) +{ + return v[0] = Qundef; +} + static VALUE zip_i(VALUE val, NODE *memo, int argc, VALUE *argv) { @@ -1357,8 +1369,20 @@ zip_i(VALUE val, NODE *memo, int argc, VALUE *argv) tmp = rb_ary_new2(RARRAY_LEN(args) + 1); rb_ary_store(tmp, 0, enum_values_pack(argc, argv)); for (i=0; iu3.value, id_each, 0, 0, zip_i, (VALUE)memo); -} - /* * call-seq: * enum.zip(arg, ...) => enumerator @@ -1401,16 +1419,19 @@ static VALUE enum_zip(int argc, VALUE *argv, VALUE obj) { int i; - VALUE result; + ID conv; NODE *memo; + VALUE result = Qnil; + conv = rb_intern("to_enum"); for (i=0; i