diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-14 02:40:04 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-14 02:40:04 +0000 |
commit | 9cabbf849e333d2e09abb323fcd3100c4ef51095 (patch) | |
tree | a759c5296b3e23c945b5a43440def840c7b35640 /compile.c | |
parent | 77c301073b4fe9497ed96f0062b0017f57141811 (diff) | |
download | ruby-9cabbf849e333d2e09abb323fcd3100c4ef51095.tar.gz |
compile.c: comments for concatstrings optimization [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -2614,6 +2614,12 @@ 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; + /* + * tostring + * concatstrings 1 + * => + * tostring + */ if (IS_INSN(next) && IS_INSN_ID(next, concatstrings) && OPERAND_AT(next, 0) == INT2FIX(1)) { REMOVE_ELEM(next); @@ -2622,6 +2628,12 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal if (IS_INSN_ID(iobj, putstring) || (IS_INSN_ID(iobj, putobject) && RB_TYPE_P(OPERAND_AT(iobj, 0), T_STRING))) { + /* + * putstring "" + * concatstrings N + * => + * concatstrings N-1 + */ if (IS_NEXT_INSN_ID(&iobj->link, concatstrings) && RSTRING_LEN(OPERAND_AT(iobj, 0)) == 0) { INSN *next = (INSN *)iobj->link.next; @@ -2633,6 +2645,12 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal } if (IS_INSN_ID(iobj, concatstrings)) { + /* + * concatstrings N + * concatstrings M + * => + * concatstrings N+M-1 + */ LINK_ELEMENT *next = iobj->link.next, *freeze = 0; INSN *jump = 0; if (IS_INSN(next) && IS_INSN_ID(next, freezestring)) |