diff options
author | Marc-André Lafortune <github@marc-andre.ca> | 2020-12-24 12:08:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-25 02:08:12 +0900 |
commit | db2ebbd71b746734b88832b1e70db8afed3d68ed (patch) | |
tree | ab48ce3cc5083b59ef7858ec9ecadc2ce018fc70 /hash.c | |
parent | 8981a63f12f9c30e9c6f893d292d01fd5df89991 (diff) |
Optimize calls to `Kernel#hash` (#3987)
This avoids recursive checks when the `hash` method of an object
isn't specialized.
Notes
Notes:
Merged-By: nurse <naruse@airemix.jp>
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -142,7 +142,11 @@ hash_recursive(VALUE obj, VALUE arg, int recurse) VALUE rb_hash(VALUE obj) { - VALUE hval = rb_exec_recursive_outer(hash_recursive, obj, 0); + VALUE hval = rb_check_funcall_basic_kw(obj, id_hash, rb_mKernel, 0, 0, 0); + + if (hval == Qundef) { + hval = rb_exec_recursive_outer(hash_recursive, obj, 0); + } while (!FIXNUM_P(hval)) { if (RB_TYPE_P(hval, T_BIGNUM)) { |