hash.c: avoid mrb_obj_id to get the hash value if possible.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-11-02 17:55:10 +09:00
parent 877e82eb92
commit c21a094a7f
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -326,8 +326,15 @@ obj_hash_code(mrb_state *mrb, mrb_value key, struct RHash *h)
case MRB_TT_TRUE:
case MRB_TT_FALSE:
case MRB_TT_SYMBOL:
hash_code = U32(mrb_fixnum(key));
break;
case MRB_TT_INTEGER:
if (mrb_fixnum_p(key)) {
hash_code = U32(mrb_fixnum(key));
break;
}
#ifndef MRB_NO_FLOAT
/* fall through */
case MRB_TT_FLOAT:
#endif
hash_code = U32(mrb_obj_id(key));
+1 -1
View File
@@ -16,7 +16,7 @@ mrb_obj_eq(mrb_state *mrb, mrb_value v1, mrb_value v2)
{
#if defined(MRB_NAN_BOXING)
return v1.u == v2.u;
#elif defined(MRB_NAN_BOXING)
#elif defined(MRB_WORD_BOXING)
return v1.w == v2.w;
#else /* MRB_NO_BOXING */
if (mrb_type(v1) != mrb_type(v2)) return FALSE;