mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
variable.c: use st_update
* variable.c (sv_i, cv_i): use st_update to insert non-existing entries. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
02fe713b46
commit
c8d7d587ac
1 changed files with 10 additions and 6 deletions
16
variable.c
16
variable.c
|
@ -1963,6 +1963,14 @@ rb_const_remove(VALUE mod, ID id)
|
|||
return val;
|
||||
}
|
||||
|
||||
static int
|
||||
cv_i_update(st_data_t *k, st_data_t *v, st_data_t a, int existing)
|
||||
{
|
||||
if (existing) return ST_STOP;
|
||||
*v = a;
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
static int
|
||||
sv_i(st_data_t k, st_data_t v, st_data_t a)
|
||||
{
|
||||
|
@ -1971,9 +1979,7 @@ sv_i(st_data_t k, st_data_t v, st_data_t a)
|
|||
st_table *tbl = (st_table *)a;
|
||||
|
||||
if (rb_is_const_id(key)) {
|
||||
if (!st_lookup(tbl, (st_data_t)key, 0)) {
|
||||
st_insert(tbl, (st_data_t)key, (st_data_t)ce);
|
||||
}
|
||||
st_update(tbl, (st_data_t)key, cv_i_update, (st_data_t)ce);
|
||||
}
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
@ -2443,9 +2449,7 @@ cv_i(st_data_t k, st_data_t v, st_data_t a)
|
|||
st_table *tbl = (st_table *)a;
|
||||
|
||||
if (rb_is_class_id(key)) {
|
||||
if (!st_lookup(tbl, (st_data_t)key, 0)) {
|
||||
st_insert(tbl, (st_data_t)key, 0);
|
||||
}
|
||||
st_update(tbl, (st_data_t)key, cv_i_update, 0);
|
||||
}
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue