summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2017-05-18 15:59:38 -0700
committer卜部昌平 <shyouhei@ruby-lang.org>2019-10-09 23:46:50 +0900
commitbb71a128eb6e901d3d7deb895971a6706eb7110d (patch)
tree5a92d96b884a39c9101286bd59e97d8df6a71245
parent29e6782f5dbf127dc20156938af374eea9e2d74e (diff)
Prefer st_is_member over st_lookup with 0
The st_is_member DEFINE has simpler semantics, for more readable code.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/1622
-rw-r--r--array.c2
-rw-r--r--class.c2
-rw-r--r--gc.c4
-rw-r--r--parse.y4
-rw-r--r--thread.c2
-rw-r--r--variable.c2
6 files changed, 8 insertions, 8 deletions
diff --git a/array.c b/array.c
index 19d9946a01..3aab2ec2a3 100644
--- a/array.c
+++ b/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");
}
diff --git a/class.c b/class.c
index b4aeb59e25..09afc720e3 100644
--- a/class.c
+++ b/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 */
}
diff --git a/gc.c b/gc.c
index 9a33da0cf2..7cc3c53d1a 100644
--- a/gc.c
+++ b/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;
}
}
diff --git a/parse.y b/parse.y
index 2fd01ddb72..cddeb3c2d5 100644
--- a/parse.y
+++ b/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 {
diff --git a/thread.c b/thread.c
index ea0956eabd..eff5d39b51 100644
--- a/thread.c
+++ b/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 {
diff --git a/variable.c b/variable.c
index aafb6f4725..b0f87923d4 100644
--- a/variable.c
+++ b/variable.c
@@ -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: