diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-11-02 17:55:10 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-11-04 15:54:31 +0900 |
| commit | c21a094a7fa51d94a78d166758b1740eb7f8b370 (patch) | |
| tree | e484fab8068d65f715a58d09c7fcf3de90b73d19 /src/hash.c | |
| parent | 877e82eb92344e1ab96ae9288667a8425b42a376 (diff) | |
| download | mruby-c21a094a7fa51d94a78d166758b1740eb7f8b370.tar.gz mruby-c21a094a7fa51d94a78d166758b1740eb7f8b370.zip | |
hash.c: avoid `mrb_obj_id` to get the hash value if possible.
Diffstat (limited to 'src/hash.c')
| -rw-r--r-- | src/hash.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/hash.c b/src/hash.c index c0d3d712f..fc6b6fa6b 100644 --- a/src/hash.c +++ b/src/hash.c @@ -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)); |
