summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-02 15:36:20 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-02 15:36:20 +0000
commit633fd55c4cc8b11af9dac78223a1e76080058525 (patch)
tree3df9d6988544d00e7582f8ca6fc43b764fa6e2a4 /array.c
parentf5c00c147113e0f7f175a491116f51a8e8ec043e (diff)
* array.c (rb_ary_zip): use rb_ary_new2() to create buffer
if rb_block_arity() > 1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/array.c b/array.c
index b1ce74f..56a5310 100644
--- a/array.c
+++ b/array.c
@@ -3162,15 +3162,14 @@ rb_ary_zip(int argc, VALUE *argv, VALUE ary)
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 {