summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorHParker <HParker@github.com>2022-09-21 13:53:10 -0700
committerJohn Hawthorn <john@hawthorn.email>2022-09-22 09:47:13 -0700
commitaafbc9068f96e5e1f7f5c2c1fa6cba01ec8422db (patch)
tree9d7bc64c416f8480af06c96e5a4fc2857c611051 /compile.c
parent4bdd8f2ddfce293136fb69257a25e29677612819 (diff)
downloadruby-aafbc9068f96e5e1f7f5c2c1fa6cba01ec8422db.tar.gz
avoid extra dup and pop in compile_op_log
Co-authored-by: John Hawthorn <jhawthorn@github.com>
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/compile.c b/compile.c
index 7d553bfba1..c6cd941d22 100644
--- a/compile.c
+++ b/compile.c
@@ -8831,7 +8831,10 @@ compile_op_log(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
}
CHECK(COMPILE(ret, "NODE_OP_ASGN_AND/OR#nd_head", node->nd_head));
- ADD_INSN(ret, node, dup);
+
+ if (!popped) {
+ ADD_INSN(ret, node, dup);
+ }
if (type == NODE_OP_ASGN_AND) {
ADD_INSNL(ret, node, branchunless, lfin);
@@ -8840,15 +8843,15 @@ compile_op_log(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
ADD_INSNL(ret, node, branchif, lfin);
}
- ADD_INSN(ret, node, pop);
- ADD_LABEL(ret, lassign);
- CHECK(COMPILE(ret, "NODE_OP_ASGN_AND/OR#nd_value", node->nd_value));
- ADD_LABEL(ret, lfin);
-
- if (popped) {
- /* we can apply more optimize */
+ if (!popped) {
ADD_INSN(ret, node, pop);
}
+
+ ADD_LABEL(ret, lassign);
+
+ CHECK(COMPILE_(ret, "NODE_OP_ASGN_AND/OR#nd_value", node->nd_value, popped));
+
+ ADD_LABEL(ret, lfin);
return COMPILE_OK;
}