From 788d30a8b388cd5500862a4015537203ef49ea85 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Thu, 6 May 2021 18:54:52 -0400 Subject: [PATCH] Make range literal peephole optimization target "newrange" It looks for "checkmatch", when it could be applied to anything that has "newrange". Making the optimization target more ranges might only be fair play when all ranges are frozen. So I'm putting a reference to the ticket that froze all ranges. [Feature #15504] --- compile.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/compile.c b/compile.c index 44fb53cefd..e8d5d0514f 100644 --- a/compile.c +++ b/compile.c @@ -3027,13 +3027,12 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal * * putobject "beg".."end" */ - if (IS_INSN_ID(iobj, checkmatch)) { - INSN *range = (INSN *)get_prev_insn(iobj); + if (IS_INSN_ID(iobj, newrange)) { + INSN *const range = iobj; INSN *beg, *end; VALUE str_beg, str_end; - if (range && IS_INSN_ID(range, newrange) && - (end = (INSN *)get_prev_insn(range)) != 0 && + if ((end = (INSN *)get_prev_insn(range)) != 0 && is_frozen_putstring(end, &str_end) && (beg = (INSN *)get_prev_insn(end)) != 0 && is_frozen_putstring(beg, &str_beg)) {