summaryrefslogtreecommitdiff
path: root/internal/basic_operators.h
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2022-12-15 10:46:24 -0800
committerJohn Hawthorn <john@hawthorn.email>2022-12-17 14:51:49 -0800
commitfbaa5db44a3b0622e2755fd00e0519a603aa9bcb (patch)
tree8333e59e1fd500adc85a563f6ea5e81bda66e756 /internal/basic_operators.h
parent632beec01f6a293aa03da06f5f0e6f9a7c22a8c5 (diff)
downloadruby-fbaa5db44a3b0622e2755fd00e0519a603aa9bcb.tar.gz
Use a BOP for Hash#default
On a hash miss we need to call default if it is redefined in order to return the default value to be used. Previously we checked this with rb_method_basic_definition_p, which avoids the method call but requires a method lookup. This commit replaces the previous check with BASIC_OP_UNREDEFINED_P and a new BOP_DEFAULT. We still need to fall back to rb_method_basic_definition_p when called on a subclasss of hash. | |compare-ruby|built-ruby| |:---------------|-----------:|---------:| |hash_aref_miss | 2.692| 3.531| | | -| 1.31x| Co-authored-by: Daniel Colson <danieljamescolson@gmail.com> Co-authored-by: "Ian C. Anderson" <ian@iancanderson.com> Co-authored-by: Jack McCracken <me@jackmc.xyz>
Diffstat (limited to 'internal/basic_operators.h')
-rw-r--r--internal/basic_operators.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/internal/basic_operators.h b/internal/basic_operators.h
index aa63c455b7..2cd9f50073 100644
--- a/internal/basic_operators.h
+++ b/internal/basic_operators.h
@@ -35,6 +35,7 @@ enum ruby_basic_operators {
BOP_AND,
BOP_OR,
BOP_CMP,
+ BOP_DEFAULT,
BOP_LAST_
};