diff options
author | Alan Wu <[email protected]> | 2024-03-20 16:21:04 -0400 |
---|---|---|
committer | Alan Wu <[email protected]> | 2024-03-21 13:20:32 -0400 |
commit | 15dc3aaa311b32203d8ffb414bcf9b8e55ce5691 (patch) | |
tree | ff16db362682fc281825b3f653853dc6059478d4 /vm_args.c | |
parent | 806edd295653a64901b49928b5b14d6c815f8e74 (diff) |
Remove excess allocation for kwsplat to kw call
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 ca204a20231. Since it targets when the callee
has no keyword parameters, skip duplicating when the method takes
keywords.
Diffstat (limited to 'vm_args.c')
-rw-r--r-- | vm_args.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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) { |