From c4e5e000195b7b4a05c463dafb75a254b6f4b965 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 11 Mar 2008 16:20:44 +0000 Subject: * enum.c (enum_zip): optimize if all arguments are arrays. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- enum.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'enum.c') diff --git a/enum.c b/enum.c index 0002cd728..05c425cb4 100644 --- a/enum.c +++ b/enum.c @@ -1346,6 +1346,36 @@ enum_each_with_index(int argc, VALUE *argv, VALUE obj) } +static VALUE +zip_ary(VALUE val, NODE *memo, int argc, VALUE *argv) +{ + volatile VALUE result = memo->u1.value; + volatile VALUE args = memo->u2.value; + int n = memo->u3.cnt++; + volatile VALUE tmp; + int i; + + tmp = rb_ary_new2(RARRAY_LEN(args) + 1); + rb_ary_store(tmp, 0, enum_values_pack(argc, argv)); + for (i=0; i