diff --git a/ChangeLog b/ChangeLog index e47ec0686e..987ac81d1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ Tue Mar 11 23:38:39 2008 Yukihiro Matsumoto * array.c (rb_ary_permutation): ditto. + * enum.c (enum_zip): optimize if all arguments are arrays. + Tue Mar 11 19:48:09 2008 Nobuyoshi Nakada * numeric.c (fix_coerce): try conversion before type check. diff --git a/enum.c b/enum.c index 0002cd7280..05c425cb42 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