From cd774f4ab916290128924a3eb121b9e56fb587d2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 27 Feb 2024 01:22:01 +0900 Subject: [PATCH] Extract `RHASH_STRING_KEY_P` --- hash.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 {