diff options
author | Alan Wu <[email protected]> | 2021-05-06 18:54:52 -0400 |
---|---|---|
committer | Alan Wu <[email protected]> | 2021-05-28 12:34:03 -0400 |
commit | 788d30a8b388cd5500862a4015537203ef49ea85 (patch) | |
tree | 7a90c542b56382b60efcf18846e04a9c1a33f55f /compile.c | |
parent | 12214b7814220389f2e1e32421699bb54f834158 (diff) |
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]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4468
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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)) { |