1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* hash.c (rb_hash_reject_bang): do not call rb_hash_foreach() if RHash

has ntbl and it is empty.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
glass 2013-07-12 02:35:16 +00:00
parent b9a9a02409
commit bc241235ac
2 changed files with 7 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Fri Jul 12 11:26:25 2013 Masaki Matsushita <glass.saga@gmail.com>
* hash.c (rb_hash_reject_bang): do not call rb_hash_foreach() if RHash
has ntbl and it is empty.
Fri Jul 12 11:17:41 2013 Masaki Matsushita <glass.saga@gmail.com> Fri Jul 12 11:17:41 2013 Masaki Matsushita <glass.saga@gmail.com>
* hash.c (recursive_hash): use RHASH_SIZE() to check hash size. * hash.c (recursive_hash): use RHASH_SIZE() to check hash size.

5
hash.c
View file

@ -1061,9 +1061,8 @@ rb_hash_reject_bang(VALUE hash)
RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
rb_hash_modify(hash); rb_hash_modify(hash);
if (!RHASH(hash)->ntbl) n = RHASH_SIZE(hash);
return Qnil; if (!n) return Qnil;
n = RHASH(hash)->ntbl->num_entries;
rb_hash_foreach(hash, delete_if_i, hash); rb_hash_foreach(hash, delete_if_i, hash);
if (n == RHASH(hash)->ntbl->num_entries) return Qnil; if (n == RHASH(hash)->ntbl->num_entries) return Qnil;
return hash; return hash;