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]
This commit is contained in:
Alan Wu 2021-05-06 18:54:52 -04:00
Родитель 12214b7814
Коммит 788d30a8b3
1 изменённых файлов: 3 добавлений и 4 удалений

Просмотреть файл

@ -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)) {