aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2023-11-06 12:37:16 -0800
committerJeremy Evans <code@jeremyevans.net>2023-12-07 11:27:55 -0800
commit1731dd05a7f9fcdef1ea1c25f7a3e072679c3d3a (patch)
tree0ee64b8f8024645de6b9972607db6c7e472a7d05 /compile.c
parentc70c1d2a9592bcea916500eb16ae58f6de4b9a3f (diff)
downloadruby-1731dd05a7f9fcdef1ea1c25f7a3e072679c3d3a.tar.gz
Eliminate array allocation for f(*a, **lvar) and f(*a, **@iv)
The compiler already eliminates the array allocation for f(*a, &lvar) and f(*a, &@iv), and eliminating the array allocation for keyword splat is as safe as eliminating it for block passes.
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 1f3b0920de..4ba332ff1f 100644
--- a/compile.c
+++ b/compile.c
@@ -3876,6 +3876,21 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
if ((flag & VM_CALL_ARGS_BLOCKARG) && !(flag & VM_CALL_KW_SPLAT)) {
OPERAND_AT(iobj, 0) = Qfalse;
}
+
+ /*
+ * Eliminate array allocation for f(*a, **lvar) and f(*a, **@iv)
+ *
+ * splatarray true
+ * getlocal / getinstancevariable
+ * send ARGS_SPLAT|KW_SPLAT and not ARGS_BLOCKARG
+ * =>
+ * splatarray false
+ * getlocal / getinstancevariable
+ * send
+ */
+ else if (!(flag & VM_CALL_ARGS_BLOCKARG) && (flag & VM_CALL_KW_SPLAT)) {
+ OPERAND_AT(iobj, 0) = Qfalse;
+ }
}
}
}