Skip to content
  • Alan Wu's avatar
    e4272fd2
    Avoid allocation when passing no keywords to anonymous kwrest methods · e4272fd2
    Alan Wu authored
    Thanks to the new semantics from [ruby-core:115808], `**nil` is now
    equivalent to `**{}`. Since the only thing one could do with anonymous
    keyword rest parameter is to delegate it with `**`, nil is just as good
    as an empty hash. Using nil avoids allocating an empty hash.
    
    This is particularly important for `...` methods since they now use
    `**kwrest` under the hood after 4f77d8d3. Most calls don't pass
    keywords.
    
        Comparison:
                                 fw_no_kw
                        post:   9816800.9 i/s
                         pre:   8570297.0 i/s - 1.15x  slower
    e4272fd2
    Avoid allocation when passing no keywords to anonymous kwrest methods
    Alan Wu authored
    Thanks to the new semantics from [ruby-core:115808], `**nil` is now
    equivalent to `**{}`. Since the only thing one could do with anonymous
    keyword rest parameter is to delegate it with `**`, nil is just as good
    as an empty hash. Using nil avoids allocating an empty hash.
    
    This is particularly important for `...` methods since they now use
    `**kwrest` under the hood after 4f77d8d3. Most calls don't pass
    keywords.
    
        Comparison:
                                 fw_no_kw
                        post:   9816800.9 i/s
                         pre:   8570297.0 i/s - 1.15x  slower
Loading