Skip to content

Commit

Permalink
compile.c: comments for r52517 [ci skip]
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Nov 11, 2015
1 parent 56e3b49 commit 66688cd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2001,11 +2001,19 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}

if (iobj->insn_id == BIN(pop)) {
/*
* putself / putnil / putobject obj / putstring "..."
* pop
* =>
* # do nothing
*/
LINK_ELEMENT *prev = iobj->link.prev;
if (prev->type == ISEQ_ELEMENT_INSN) {
enum ruby_vminsn_type previ = ((INSN *)prev)->insn_id;
if (previ == BIN(putobject) || previ == BIN(putnil) ||
previ == BIN(putself) || previ == BIN(putstring)) {
/* just push operand or static value and pop soon, no
* side effects */
REMOVE_ELEM(prev);
REMOVE_ELEM(&iobj->link);
}
Expand Down

0 comments on commit 66688cd

Please sign in to comment.