summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2024-02-26 23:47:45 +0900
committernagachika <nagachika@ruby-lang.org>2024-07-13 15:40:01 +0900
commit3faef1d40dc1d6eea8ffcd624528f431ccaf0a5b (patch)
tree0cec0ca8a12a5c03f34f01459d732ee789dcf0b0
parent584a02aaafda74c21d24dc4c5e223a2482c7fde3 (diff)
Extract `RHASH_IDENTHASH_P`
-rw-r--r--hash.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index 51cc392fbd..743cd847a7 100644
--- a/hash.c
+++ b/hash.c
@@ -361,6 +361,8 @@ const struct st_hash_type rb_hashtype_ident = {
rb_ident_hash,
};
+#define RHASH_IDENTHASH_P(hash) (RHASH_TYPE(hash) == &identhash)
+
typedef st_index_t st_hash_t;
/*
@@ -3006,7 +3008,7 @@ rb_hash_aset(VALUE hash, VALUE key, VALUE val)
ar_alloc_table(hash);
}
- if (RHASH_TYPE(hash) == &identhash || rb_obj_class(key) != rb_cString) {
+ if (RHASH_IDENTHASH_P(hash) || rb_obj_class(key) != rb_cString) {
RHASH_UPDATE_ITER(hash, iter_lev, key, hash_aset, val);
}
else {
@@ -4241,7 +4243,7 @@ rb_hash_assoc(VALUE hash, VALUE key)
table = RHASH_ST_TABLE(hash);
orighash = table->type;
- if (orighash != &identhash) {
+ if (!RHASH_IDENTHASH_P(orighash)) {
VALUE value;
struct reset_hash_type_arg ensure_arg;
struct st_hash_type assochash;
@@ -4501,7 +4503,7 @@ rb_hash_compare_by_id(VALUE hash)
MJIT_FUNC_EXPORTED VALUE
rb_hash_compare_by_id_p(VALUE hash)
{
- return RBOOL(RHASH_ST_TABLE_P(hash) && RHASH_ST_TABLE(hash)->type == &identhash);
+ return RBOOL(RHASH_IDENTHASH_P(hash));
}
VALUE