summaryrefslogtreecommitdiff
path: root/vm_args.c
diff options
context:
space:
mode:
authorAlan Wu <[email protected]>2024-03-20 16:21:04 -0400
committerAlan Wu <[email protected]>2024-03-21 13:20:32 -0400
commit15dc3aaa311b32203d8ffb414bcf9b8e55ce5691 (patch)
treeff16db362682fc281825b3f653853dc6059478d4 /vm_args.c
parent806edd295653a64901b49928b5b14d6c815f8e74 (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.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/vm_args.c b/vm_args.c
index d1a7695c6e..aa800319df 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -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) {