summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2024-02-27 01:22:01 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-03-14 17:49:37 +0900
commitcd774f4ab916290128924a3eb121b9e56fb587d2 (patch)
tree8965c99f08621d9826abd51daee26c33f47ba82c /hash.c
parentc1279a3da53d2869181cbc232213213b8bd99db7 (diff)
Extract `RHASH_STRING_KEY_P`
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index 2da4c2f8a7..f8c84652cd 100644
--- a/hash.c
+++ b/hash.c
@@ -395,6 +395,7 @@ const struct st_hash_type rb_hashtype_ident = {
};
#define RHASH_IDENTHASH_P(hash) (RHASH_TYPE(hash) == &identhash)
+#define RHASH_STRING_KEY_P(hash, key) (!RHASH_IDENTHASH_P(hash) && (rb_obj_class(key) == rb_cString))
typedef st_index_t st_hash_t;
@@ -2958,7 +2959,7 @@ rb_hash_aset(VALUE hash, VALUE key, VALUE val)
rb_hash_modify(hash);
- if (RHASH_IDENTHASH_P(hash) || rb_obj_class(key) != rb_cString) {
+ if (!RHASH_STRING_KEY_P(hash, key)) {
RHASH_UPDATE_ITER(hash, iter_p, key, hash_aset, val);
}
else {