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 21, 2024
1 parent 806edd2 commit 15dc3aa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion vm_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,9 @@ 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);
kw_flag |= VM_CALL_KW_SPLAT_MUT;
}

if (last_arg != converted_keyword_hash) {
Expand Down

0 comments on commit 15dc3aa

Please sign in to comment.