ruby-changes:30322
From: glass <ko1@a...>
Date: Sun, 4 Aug 2013 21:24:40 +0900 (JST)
Subject: [ruby-changes:30322] glass:r42374 (trunk): * array.c (rb_ary_zip): performance implement by using
glass 2013-08-04 21:24:26 +0900 (Sun, 04 Aug 2013) New Revision: 42374 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42374 Log: * array.c (rb_ary_zip): performance implement by using ALLOCA_N() to allocate tmp buffer. Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 42373) +++ array.c (revision 42374) @@ -3161,15 +3161,15 @@ rb_ary_zip(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L3161 else result = rb_ary_new2(len); - if (block_given && arity > 1) { - VALUE tmp = rb_ary_new2(argc+1); + if (block_given && arity > 1 && argc+1 < 0x100) { + VALUE *tmp = ALLOCA_N(VALUE, argc+1); for (i=0; i<RARRAY_LEN(ary); i++) { - rb_ary_store(tmp, 0, RARRAY_AREF(ary, i)); + tmp[0] = RARRAY_AREF(ary, i); for (j=0; j<argc; j++) { - rb_ary_store(tmp, j+1, rb_ary_elt(argv[j], i)); + tmp[j+1] = rb_ary_elt(argv[j], i); } - rb_yield_values2(argc+1, RARRAY_RAWPTR(tmp)); + rb_yield_values2(argc+1, tmp); } } else { Index: ChangeLog =================================================================== --- ChangeLog (revision 42373) +++ ChangeLog (revision 42374) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Aug 4 21:08:29 2013 Masaki Matsushita <glass.saga@g...> + + * array.c (rb_ary_zip): performance implement by using + ALLOCA_N() to allocate tmp buffer. + Sun Aug 4 07:14:49 2013 Tanaka Akira <akr@f...> * README.EXT, README.EXT.ja: Mention rb_integer_pack and -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/