From 9cabbf849e333d2e09abb323fcd3100c4ef51095 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 14 Nov 2017 02:40:04 +0000 Subject: 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 --- compile.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'compile.c') diff --git a/compile.c b/compile.c index b79f970cf4..9ecb7c6d80 100644 --- a/compile.c +++ b/compile.c @@ -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)) -- cgit v1.2.3