summaryrefslogtreecommitdiff
path: root/vm_args.c
diff options
context:
space:
mode:
authorJeremy Evans <[email protected]>2024-07-12 14:19:40 -0700
committerJeremy Evans <[email protected]>2024-07-18 22:17:21 -0700
commit1cc5a64dd87a6a474ec8387083d41a3c6c1c3ca5 (patch)
tree7fa2e9963e3d3ec1a0011d4924916c9632a600c4 /vm_args.c
parent4a49b060ae04b3ccb3880854ba08c6629344f7b3 (diff)
Avoid hash allocation for f(*r2k_ary) when def f(kw: 1)
When calling a method that accepts keywords but not a keyword splat with a splatted array with a ruby2_keywords flagged hash, there is no need to duplicate the ruby2_keywords flagged hash, since it will be accessed to get the keyword values, but it will not be modified.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11161
Diffstat (limited to 'vm_args.c')
-rw-r--r--vm_args.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/vm_args.c b/vm_args.c
index 4449113790..abd9cf75f6 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -718,7 +718,7 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co
if (RB_TYPE_P(rest_last, T_HASH) && FL_TEST_RAW(rest_last, RHASH_PASS_AS_KEYWORDS)) {
// def f(**kw); a = [..., kw]; g(*a)
splat_flagged_keyword_hash = rest_last;
- if (!RHASH_EMPTY_P(rest_last) || (ISEQ_BODY(iseq)->param.flags.has_kwrest)) {
+ if (!(RHASH_EMPTY_P(rest_last) || ISEQ_BODY(iseq)->param.flags.has_kw) || (ISEQ_BODY(iseq)->param.flags.has_kwrest)) {
rest_last = rb_hash_dup(rest_last);
}
kw_flag |= VM_CALL_KW_SPLAT | VM_CALL_KW_SPLAT_MUT;