diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-17 09:21:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-17 09:21:47 +0000 |
commit | 08bb3640d750980b634e93972ed3761582f8e364 (patch) | |
tree | 732f9ca134679483380bebe1a6d6a75f4d556501 /compile.c | |
parent | f3a491d93271df831cadc58f02b2b67202615ee3 (diff) |
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
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -2509,6 +2509,14 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal } } + 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) || |