diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-02 05:29:11 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-02 05:29:11 +0000 |
commit | fe5d876d1a015e2fd10620d19907efae4ed6f77d (patch) | |
tree | b765ebc3636c4e8691c60436db1f325a03f63e8f /vm_eval.c | |
parent | 53e1837ad9197a522facfde368011c164c08567f (diff) | |
download | ruby-fe5d876d1a015e2fd10620d19907efae4ed6f77d.tar.gz |
vm_eval.c: add rb_yield_assoc_or_values()
The new function rb_yield_assoc_or_values() will reduce branching.
* vm_eval.c: add rb_yield_assoc_or_values()
* internal.h: ditto
* hash.c: use rb_yield_assoc_or_values()
* struct.c: ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_eval.c')
-rw-r--r-- | vm_eval.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -1010,6 +1010,18 @@ rb_yield_values2(int argc, const VALUE *argv) } VALUE +rb_yield_assoc_or_values(VALUE key, VALUE value) +{ + if (rb_block_arity() > 1) { + VALUE argv[2] = { key, value }; + return rb_yield_0(2, argv); + } + else { + return rb_yield_1(rb_assoc_new(key, value)); + } +} + +VALUE rb_yield_splat(VALUE values) { VALUE tmp = rb_check_array_type(values); |