mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* hash.c: do not allocate st_table when it is not necessary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5f81a53fd2
commit
e8a1874c19
2 changed files with 25 additions and 17 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sat Mar 31 14:16:02 2012 Sokolov Yura (funny-falcon) <funny.falcon@gmail.com>
|
||||||
|
|
||||||
|
* hash.c: do not allocate st_table when it is not necessary.
|
||||||
|
|
||||||
Sat Mar 31 13:42:39 2012 Shugo Maeda <shugo@ruby-lang.org>
|
Sat Mar 31 13:42:39 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/ftp.rb (read_timeout=, open_timeout=): supported timeout.
|
* lib/net/ftp.rb (read_timeout=, open_timeout=): supported timeout.
|
||||||
|
|
20
hash.c
20
hash.c
|
@ -649,7 +649,7 @@ rb_hash_default(int argc, VALUE *argv, VALUE hash)
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_hash_set_default(VALUE hash, VALUE ifnone)
|
rb_hash_set_default(VALUE hash, VALUE ifnone)
|
||||||
{
|
{
|
||||||
rb_hash_modify(hash);
|
rb_hash_modify_check(hash);
|
||||||
RHASH_IFNONE(hash) = ifnone;
|
RHASH_IFNONE(hash) = ifnone;
|
||||||
FL_UNSET(hash, HASH_PROC_DEFAULT);
|
FL_UNSET(hash, HASH_PROC_DEFAULT);
|
||||||
return ifnone;
|
return ifnone;
|
||||||
|
@ -697,7 +697,7 @@ rb_hash_set_default_proc(VALUE hash, VALUE proc)
|
||||||
{
|
{
|
||||||
VALUE b;
|
VALUE b;
|
||||||
|
|
||||||
rb_hash_modify(hash);
|
rb_hash_modify_check(hash);
|
||||||
b = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc");
|
b = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc");
|
||||||
if (NIL_P(b) || !rb_obj_is_proc(b)) {
|
if (NIL_P(b) || !rb_obj_is_proc(b)) {
|
||||||
rb_raise(rb_eTypeError,
|
rb_raise(rb_eTypeError,
|
||||||
|
@ -799,7 +799,7 @@ rb_hash_delete(VALUE hash, VALUE key)
|
||||||
{
|
{
|
||||||
VALUE val;
|
VALUE val;
|
||||||
|
|
||||||
rb_hash_modify(hash);
|
rb_hash_modify_check(hash);
|
||||||
val = rb_hash_delete_key(hash, key);
|
val = rb_hash_delete_key(hash, key);
|
||||||
if (val != Qundef) return val;
|
if (val != Qundef) return val;
|
||||||
if (rb_block_given_p()) {
|
if (rb_block_given_p()) {
|
||||||
|
@ -852,7 +852,8 @@ rb_hash_shift(VALUE hash)
|
||||||
{
|
{
|
||||||
struct shift_var var;
|
struct shift_var var;
|
||||||
|
|
||||||
rb_hash_modify(hash);
|
rb_hash_modify_check(hash);
|
||||||
|
if (RHASH(hash)->ntbl) {
|
||||||
var.key = Qundef;
|
var.key = Qundef;
|
||||||
rb_hash_foreach(hash, RHASH(hash)->iter_lev > 0 ? shift_i_safe : shift_i,
|
rb_hash_foreach(hash, RHASH(hash)->iter_lev > 0 ? shift_i_safe : shift_i,
|
||||||
(VALUE)&var);
|
(VALUE)&var);
|
||||||
|
@ -863,7 +864,8 @@ rb_hash_shift(VALUE hash)
|
||||||
}
|
}
|
||||||
return rb_assoc_new(var.key, var.val);
|
return rb_assoc_new(var.key, var.val);
|
||||||
}
|
}
|
||||||
else if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
|
}
|
||||||
|
if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
|
||||||
return rb_funcall(RHASH_IFNONE(hash), id_yield, 2, hash, Qnil);
|
return rb_funcall(RHASH_IFNONE(hash), id_yield, 2, hash, Qnil);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -899,7 +901,8 @@ VALUE
|
||||||
rb_hash_delete_if(VALUE hash)
|
rb_hash_delete_if(VALUE hash)
|
||||||
{
|
{
|
||||||
RETURN_ENUMERATOR(hash, 0, 0);
|
RETURN_ENUMERATOR(hash, 0, 0);
|
||||||
rb_hash_modify(hash);
|
rb_hash_modify_check(hash);
|
||||||
|
if (RHASH(hash)->ntbl)
|
||||||
rb_hash_foreach(hash, delete_if_i, hash);
|
rb_hash_foreach(hash, delete_if_i, hash);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
@ -1025,7 +1028,7 @@ rb_hash_select_bang(VALUE hash)
|
||||||
st_index_t n;
|
st_index_t n;
|
||||||
|
|
||||||
RETURN_ENUMERATOR(hash, 0, 0);
|
RETURN_ENUMERATOR(hash, 0, 0);
|
||||||
rb_hash_modify(hash);
|
rb_hash_modify_check(hash);
|
||||||
if (!RHASH(hash)->ntbl)
|
if (!RHASH(hash)->ntbl)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
n = RHASH(hash)->ntbl->num_entries;
|
n = RHASH(hash)->ntbl->num_entries;
|
||||||
|
@ -1050,7 +1053,8 @@ VALUE
|
||||||
rb_hash_keep_if(VALUE hash)
|
rb_hash_keep_if(VALUE hash)
|
||||||
{
|
{
|
||||||
RETURN_ENUMERATOR(hash, 0, 0);
|
RETURN_ENUMERATOR(hash, 0, 0);
|
||||||
rb_hash_modify(hash);
|
rb_hash_modify_check(hash);
|
||||||
|
if (RHASH(hash)->ntbl)
|
||||||
rb_hash_foreach(hash, keep_if_i, hash);
|
rb_hash_foreach(hash, keep_if_i, hash);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue