ruby-changes:30288
From: glass <ko1@a...>
Date: Sat, 3 Aug 2013 00:36:32 +0900 (JST)
Subject: [ruby-changes:30288] glass:r42340 (trunk): * array.c (rb_ary_zip): use rb_ary_new2() to create buffer
glass 2013-08-03 00:36:20 +0900 (Sat, 03 Aug 2013) New Revision: 42340 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42340 Log: * array.c (rb_ary_zip): use rb_ary_new2() to create buffer if rb_block_arity() > 1. Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 42339) +++ array.c (revision 42340) @@ -3162,15 +3162,14 @@ rb_ary_zip(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L3162 result = rb_ary_new2(len); if (block_given && arity > 1) { - int yield_argc = argc + 1; - VALUE *yield_argv = ALLOC_N(VALUE, yield_argc); + VALUE tmp = rb_ary_new2(argc+1); for (i=0; i<RARRAY_LEN(ary); i++) { - yield_argv[0] = RARRAY_AREF(ary, i); + rb_ary_store(tmp, 0, RARRAY_AREF(ary, i)); for (j=0; j<argc; j++) { - yield_argv[j+1] = rb_ary_elt(argv[j], i); + rb_ary_store(tmp, j+1, rb_ary_elt(argv[j], i)); } - rb_yield_values2(yield_argc, yield_argv); + rb_yield_values2(argc+1, RARRAY_RAWPTR(tmp)); } } else { Index: ChangeLog =================================================================== --- ChangeLog (revision 42339) +++ ChangeLog (revision 42340) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Aug 3 00:34:20 2013 Masaki Matsushita <glass.saga@g...> + + * array.c (rb_ary_zip): use rb_ary_new2() to create buffer + if rb_block_arity() > 1. + Sat Aug 3 00:12:00 2013 Masaki Matsushita <glass.saga@g...> * NEWS: Add the description that IO#seek supports SEEK_DATA -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/