ruby-changes:47827
From: nobu <ko1@a...>
Date: Sun, 17 Sep 2017 18:21:51 +0900 (JST)
Subject: [ruby-changes:47827] nobu:r59945 (trunk): compile.c: optimize unnecessary concatstrings
nobu 2017-09-17 18:21:47 +0900 (Sun, 17 Sep 2017) New Revision: 59945 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59945 Log: compile.c: optimize unnecessary concatstrings * compile.c (iseq_peephole_optimize): optimize away unnecessary concatenation of single string, following tostring which always puts a String instance. https://github.com/ruby/ruby/pull/1626#discussion_r139285653 Modified files: trunk/compile.c Index: compile.c =================================================================== --- compile.c (revision 59944) +++ compile.c (revision 59945) @@ -2509,6 +2509,14 @@ iseq_peephole_optimize(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/compile.c#L2509 } } + if (IS_INSN_ID(iobj, tostring)) { + LINK_ELEMENT *next = iobj->link.next; + if (IS_INSN(next) && IS_INSN_ID(next, concatstrings) && + OPERAND_AT(next, 0) == INT2FIX(1)) { + REMOVE_ELEM(next); + } + } + if (do_tailcallopt && (IS_INSN_ID(iobj, send) || IS_INSN_ID(iobj, opt_aref_with) || -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/