mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* hash.c (rb_hash_each_pair): performance improvement by using
rb_block_arity(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f344841e30
commit
b9d2960337
2 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Jul 15 13:36:02 2013 Masaki Matsushita <glass.saga@gmail.com>
|
||||
|
||||
* hash.c (rb_hash_each_pair): performance improvement by using
|
||||
rb_block_arity().
|
||||
|
||||
Mon Jul 15 13:15:37 2013 Masaki Matsushita <glass.saga@gmail.com>
|
||||
|
||||
* proc.c (rb_block_arity): create internal API rb_block_arity().
|
||||
|
|
12
hash.c
12
hash.c
|
@ -1472,6 +1472,13 @@ each_pair_i(VALUE key, VALUE value)
|
|||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
static int
|
||||
each_pair_i_fast(VALUE key, VALUE value)
|
||||
{
|
||||
rb_yield_values(2, key, value);
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* hsh.each {| key, value | block } -> hsh
|
||||
|
@ -1498,7 +1505,10 @@ static VALUE
|
|||
rb_hash_each_pair(VALUE hash)
|
||||
{
|
||||
RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
|
||||
rb_hash_foreach(hash, each_pair_i, 0);
|
||||
if (rb_block_arity() > 1)
|
||||
rb_hash_foreach(hash, each_pair_i_fast, 0);
|
||||
else
|
||||
rb_hash_foreach(hash, each_pair_i, 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue