summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-04 12:24:26 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-04 12:24:26 +0000
commit07e3b30c8498672541200d22cf7b77d7a090a958 (patch)
treefde7f9d2dee4cc36663b536e18aac4d99f82e878 /array.c
parent0d5ec8a346cfd6bd7152f6f31dcda06421b15396 (diff)
* array.c (rb_ary_zip): performance implement by using
ALLOCA_N() to allocate tmp buffer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/array.c b/array.c
index 56a5310..666ac81 100644
--- a/array.c
+++ b/array.c
@@ -3161,15 +3161,15 @@ rb_ary_zip(int argc, VALUE *argv, VALUE ary)
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 {