diff options
author | HParker <HParker@github.com> | 2022-09-21 13:53:10 -0700 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2022-09-22 09:47:13 -0700 |
commit | aafbc9068f96e5e1f7f5c2c1fa6cba01ec8422db (patch) | |
tree | 9d7bc64c416f8480af06c96e5a4fc2857c611051 /compile.c | |
parent | 4bdd8f2ddfce293136fb69257a25e29677612819 (diff) |
avoid extra dup and pop in compile_op_log
Co-authored-by: John Hawthorn <jhawthorn@github.com>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6414
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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; } |