Skip to content
  • John Hawthorn's avatar
    fbaa5db4
    Use a BOP for Hash#default · fbaa5db4
    John Hawthorn authored
    
    
    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: default avatarDaniel Colson <danieljamescolson@gmail.com>
    Co-authored-by: default avatar"Ian C. Anderson" <ian@iancanderson.com>
    Co-authored-by: default avatarJack McCracken <me@jackmc.xyz>
    fbaa5db4
    Use a BOP for Hash#default
    John Hawthorn authored
    
    
    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: default avatarDaniel Colson <danieljamescolson@gmail.com>
    Co-authored-by: default avatar"Ian C. Anderson" <ian@iancanderson.com>
    Co-authored-by: default avatarJack McCracken <me@jackmc.xyz>
Loading