mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* hash.c (rb_hash_clear): use st_clear() unless iterating.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
be4fc7941b
commit
271aaf297e
2 changed files with 7 additions and 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
|
* st.c (struct st_table_entry): add new members, fore and back, to
|
||||||
iterate in inserted order.
|
iterate in inserted order.
|
||||||
|
|
5
hash.c
5
hash.c
|
@ -842,7 +842,10 @@ rb_hash_clear(VALUE hash)
|
||||||
{
|
{
|
||||||
rb_hash_modify(hash);
|
rb_hash_modify(hash);
|
||||||
if (RHASH(hash)->tbl->num_entries > 0) {
|
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;
|
return hash;
|
||||||
|
|
Loading…
Add table
Reference in a new issue