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

parent 877e82eb
......@@ -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));
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment