summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index 20bc33b87..910676f49 100644
--- a/hash.c
+++ b/hash.c
@@ -842,7 +842,10 @@ rb_hash_clear(VALUE hash)
{
rb_hash_modify(hash);
if (RHASH(hash)->tbl->num_entries > 0) {
- rb_hash_foreach(hash, clear_i, 0);
+ if (RHASH(hash)->iter_lev > 0)
+ rb_hash_foreach(hash, clear_i, 0);
+ else
+ st_clear(RHASH(hash)->tbl);
}
return hash;