diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-21 04:47:01 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-21 04:47:01 +0000 |
| commit | 76d73b5e3686123dd686833abf17628a28509a3d (patch) | |
| tree | d739fff49bee78a0c51bb361a429e36be7a79605 | |
| parent | 74e1b7d9e3df48070d81038b9809494afc513b5f (diff) | |
| download | ruby-76d73b5e3686123dd686833abf17628a28509a3d.tar.gz ruby-76d73b5e3686123dd686833abf17628a28509a3d.tar.xz ruby-76d73b5e3686123dd686833abf17628a28509a3d.zip | |
* hash.c (rb_hash_clear): use st_clear() unless iterating.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | hash.c | 5 |
2 files changed, 7 insertions, 2 deletions
@@ -1,4 +1,6 @@ -Tue Aug 21 13:43:49 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> +Tue Aug 21 13:46:59 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * hash.c (rb_hash_clear): use st_clear() unless iterating. * st.c (struct st_table_entry): add new members, fore and back, to iterate in inserted order. @@ -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; |
