aboutsummaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-23 03:17:38 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-23 03:17:38 +0000
commit7eaee5b5e24bcd9e0a43656d7785805798fc4d56 (patch)
tree33cb90b505db76fc5b14913157da038f0b23cc9c /hash.c
parentd190241a9e8623b1740d7f2357b5bc6baa372a43 (diff)
downloadruby-7eaee5b5e24bcd9e0a43656d7785805798fc4d56.tar.gz
* hash.c (env_each_pair): do not call rb_assoc_new() if
it isn't needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index 1098118737..8c72da2c05 100644
--- a/hash.c
+++ b/hash.c
@@ -2901,8 +2901,15 @@ env_each_pair(VALUE ehash)
}
FREE_ENVIRON(environ);
- for (i=0; i<RARRAY_LEN(ary); i+=2) {
- rb_yield(rb_assoc_new(RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1)));
+ if (rb_block_arity() > 1) {
+ for (i=0; i<RARRAY_LEN(ary); i+=2) {
+ rb_yield_values(2, RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1));
+ }
+ }
+ else {
+ for (i=0; i<RARRAY_LEN(ary); i+=2) {
+ rb_yield(rb_assoc_new(RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1)));
+ }
}
return ehash;
}