Skip to content

Commit

Permalink
Remove excess allocation for kwsplat to kw call
Browse files Browse the repository at this point in the history
Previously, calls like the following duplicated the kwsplat hash
unnecessarily:

```ruby
def foo(a:) = a
hash = {a: 10}
foo(**hash)
```

This is due to the fix in ca204a2. Since it targets when the callee
has no keyword parameters, skip duplicating when the method takes
keywords.
  • Loading branch information
XrXr committed Mar 20, 2024
1 parent 0e8b6c6 commit be2f17b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion vm_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co
kw_flag &= ~(VM_CALL_KW_SPLAT | VM_CALL_KW_SPLAT_MUT);
}
else {
if (!(kw_flag & VM_CALL_KW_SPLAT_MUT)) {
if (!(kw_flag & VM_CALL_KW_SPLAT_MUT) && !ISEQ_BODY(iseq)->param.flags.has_kw) {
converted_keyword_hash = rb_hash_dup(converted_keyword_hash);
}

Expand Down

0 comments on commit be2f17b

Please sign in to comment.