summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-12 02:35:16 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-12 02:35:16 +0000
commitbc241235ac4d02638dfe56d2d87b8cb906400f9d (patch)
tree56a681dff299cf999b45b41890c970d8e96fdda4
parentb9a9a024094026ee5151de237c4d2ae8111ddc03 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--hash.c5
2 files changed, 7 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f692f2651b..b3b5a92dd2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* hash.c (recursive_hash): use RHASH_SIZE() to check hash size.
diff --git a/hash.c b/hash.c
index 95fea9e96da..182a856a38f 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;