mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Prefer st_is_member over st_lookup with 0
The st_is_member DEFINE has simpler semantics, for more readable code.
This commit is contained in:
parent
29e6782f5d
commit
bb71a128eb
Notes:
git
2019-10-09 23:47:12 +09:00
6 changed files with 8 additions and 8 deletions
2
array.c
2
array.c
|
@ -5209,7 +5209,7 @@ flatten(VALUE ary, int level)
|
|||
}
|
||||
else {
|
||||
id = (st_data_t)tmp;
|
||||
if (st_lookup(memo, id, 0)) {
|
||||
if (st_is_member(memo, id)) {
|
||||
st_clear(memo);
|
||||
rb_raise(rb_eArgError, "tried to flatten recursive array");
|
||||
}
|
||||
|
|
2
class.c
2
class.c
|
@ -1176,7 +1176,7 @@ method_entry_i(ID key, VALUE value, void *data)
|
|||
if (!me) return ID_TABLE_CONTINUE;
|
||||
if (!arg->recur && me->owner != owner) return ID_TABLE_CONTINUE;
|
||||
}
|
||||
if (!st_lookup(arg->list, key, 0)) {
|
||||
if (!st_is_member(arg->list, key)) {
|
||||
if (UNDEFINED_METHOD_ENTRY_P(me)) {
|
||||
type = METHOD_VISI_UNDEF; /* none */
|
||||
}
|
||||
|
|
4
gc.c
4
gc.c
|
@ -3634,7 +3634,7 @@ cached_object_id(VALUE obj)
|
|||
|
||||
while (1) {
|
||||
/* id is the object id */
|
||||
if (st_lookup(objspace->id_to_obj_tbl, (st_data_t)id, 0)) {
|
||||
if (st_is_member(objspace->id_to_obj_tbl, (st_data_t)id)) {
|
||||
objspace->profile.object_id_collisions++;
|
||||
id += sizeof(VALUE);
|
||||
}
|
||||
|
@ -7515,7 +7515,7 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
|
|||
case T_NODE:
|
||||
case T_CLASS:
|
||||
if (FL_TEST(obj, FL_FINALIZE)) {
|
||||
if (st_lookup(finalizer_table, obj, 0)) {
|
||||
if (st_is_member(finalizer_table, obj)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
4
parse.y
4
parse.y
|
@ -821,7 +821,7 @@ new_unique_key_hash(struct parser_params *p, VALUE ary, const YYLTYPE *loc)
|
|||
goto error;
|
||||
}
|
||||
if (!RB_TYPE_P(key, T_STRING)) goto error;
|
||||
if (st_lookup(tbl, (st_data_t)RSTRING_PTR(key), 0)) goto error;
|
||||
if (st_is_member(tbl, (st_data_t)RSTRING_PTR(key))) goto error;
|
||||
st_insert(tbl, (st_data_t)RSTRING_PTR(key), (st_data_t)ary);
|
||||
}
|
||||
st_free_table(tbl);
|
||||
|
@ -11463,7 +11463,7 @@ error_duplicate_keys(struct parser_params *p, NODE *hash)
|
|||
if (nd_type(head) != NODE_LIT) {
|
||||
yyerror1(&head->nd_loc, "key must be symbol literal");
|
||||
}
|
||||
if (st_lookup(literal_keys, (key = head->nd_lit), 0)) {
|
||||
if (st_is_member(literal_keys, (key = head->nd_lit))) {
|
||||
yyerror1(&head->nd_loc, "duplicated key name");
|
||||
}
|
||||
else {
|
||||
|
|
2
thread.c
2
thread.c
|
@ -3472,7 +3472,7 @@ rb_thread_key_p(VALUE self, VALUE key)
|
|||
if (!id || local_storage == NULL) {
|
||||
return Qfalse;
|
||||
}
|
||||
else if (st_lookup(local_storage, id, 0)) {
|
||||
else if (st_is_member(local_storage, id)) {
|
||||
return Qtrue;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1335,7 +1335,7 @@ rb_ivar_defined(VALUE obj, ID id)
|
|||
break;
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
if (RCLASS_IV_TBL(obj) && st_lookup(RCLASS_IV_TBL(obj), (st_data_t)id, 0))
|
||||
if (RCLASS_IV_TBL(obj) && st_is_member(RCLASS_IV_TBL(obj), (st_data_t)id))
|
||||
return Qtrue;
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue