mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* hash.c (rb_hash_reject_bang): always check frozen status.
[ruby-core:23715] * hash.c (rb_hash_update): ditto. * hash.c (rb_hash_reject_bang): call rb_hash_foreach() directly. * hash.c (rb_hash_update_i): call st_insert() directly. * hash.c (rb_hash_update_block_i): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0cdfbc9446
commit
33a8def1e1
2 changed files with 18 additions and 3 deletions
13
ChangeLog
13
ChangeLog
|
@ -9,6 +9,19 @@ Sun Jun 7 22:44:20 2009 Tadayoshi Funaba <tadf@dotrb.org>
|
|||
|
||||
* lib/cmath.rb (log): avoided redundant expression.
|
||||
|
||||
Sat Jun 6 02:49:05 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* hash.c (rb_hash_reject_bang): always check frozen status.
|
||||
[ruby-core:23715]
|
||||
|
||||
* hash.c (rb_hash_update): ditto.
|
||||
|
||||
* hash.c (rb_hash_reject_bang): call rb_hash_foreach() directly.
|
||||
|
||||
* hash.c (rb_hash_update_i): call st_insert() directly.
|
||||
|
||||
* hash.c (rb_hash_update_block_i): ditto.
|
||||
|
||||
Fri Jun 5 07:12:32 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/mkmf.rb (#link_command): should dup CONFTEST_C which is
|
||||
|
|
8
hash.c
8
hash.c
|
@ -882,10 +882,11 @@ rb_hash_reject_bang(VALUE hash)
|
|||
st_index_t n;
|
||||
|
||||
RETURN_ENUMERATOR(hash, 0, 0);
|
||||
rb_hash_modify(hash);
|
||||
if (!RHASH(hash)->ntbl)
|
||||
return Qnil;
|
||||
n = RHASH(hash)->ntbl->num_entries;
|
||||
rb_hash_delete_if(hash);
|
||||
rb_hash_foreach(hash, delete_if_i, hash);
|
||||
if (n == RHASH(hash)->ntbl->num_entries) return Qnil;
|
||||
return hash;
|
||||
}
|
||||
|
@ -1601,7 +1602,7 @@ static int
|
|||
rb_hash_update_i(VALUE key, VALUE value, VALUE hash)
|
||||
{
|
||||
if (key == Qundef) return ST_CONTINUE;
|
||||
rb_hash_aset(hash, key, value);
|
||||
st_insert(RHASH(hash)->ntbl, key, value);
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -1612,7 +1613,7 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
|
|||
if (rb_hash_has_key(hash, key)) {
|
||||
value = rb_yield_values(3, key, rb_hash_aref(hash, key), value);
|
||||
}
|
||||
rb_hash_aset(hash, key, value);
|
||||
st_insert(RHASH(hash)->ntbl, key, value);
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -1642,6 +1643,7 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
|
|||
static VALUE
|
||||
rb_hash_update(VALUE hash1, VALUE hash2)
|
||||
{
|
||||
rb_hash_modify(hash1);
|
||||
hash2 = to_hash(hash2);
|
||||
if (rb_block_given_p()) {
|
||||
rb_hash_foreach(hash2, rb_hash_update_block_i, hash1);
|
||||
|
|
Loading…
Reference in a new issue