From fbaa5db44a3b0622e2755fd00e0519a603aa9bcb Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Thu, 15 Dec 2022 10:46:24 -0800 Subject: 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 Co-authored-by: "Ian C. Anderson" Co-authored-by: Jack McCracken --- internal/basic_operators.h | 1 + 1 file changed, 1 insertion(+) (limited to 'internal') 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_ }; -- cgit v1.2.3