diff --git a/ChangeLog b/ChangeLog index 2f692f2651..b3b5a92dd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 12 11:26:25 2013 Masaki Matsushita + + * 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 * hash.c (recursive_hash): use RHASH_SIZE() to check hash size. diff --git a/hash.c b/hash.c index 95fea9e96d..182a856a38 100644 --- a/hash.c +++ b/hash.c @@ -1061,9 +1061,8 @@ rb_hash_reject_bang(VALUE hash) RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); rb_hash_modify(hash); - if (!RHASH(hash)->ntbl) - return Qnil; - n = RHASH(hash)->ntbl->num_entries; + n = RHASH_SIZE(hash); + if (!n) return Qnil; rb_hash_foreach(hash, delete_if_i, hash); if (n == RHASH(hash)->ntbl->num_entries) return Qnil; return hash;