Skip to content

Commit e95ec34

Browse files
committed
peep.c: remove childless OP_NULL nodes in a list
1 parent 22496f1 commit e95ec34

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

peep.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3124,6 +3124,23 @@ Perl_rpeep(pTHX_ OP *o)
31243124

31253125
case OP_PUSHMARK:
31263126

3127+
/* Given
3128+
pushmark
3129+
null
3130+
something_else
3131+
Take out the null wherever possible.
3132+
*/
3133+
while (OP_TYPE_IS(o->op_next, OP_NULL)) {
3134+
OP* next = o->op_next;
3135+
o->op_next = next->op_next;
3136+
if (OpSIBLING(o) == next &&
3137+
next->op_moresib &&
3138+
!(next->op_flags & OPf_KIDS)) {
3139+
op_sibling_splice(NULL, o, 1, NULL);
3140+
op_free(next);
3141+
}
3142+
}
3143+
31273144
/* Given
31283145
5 repeat/DOLIST
31293146
3 ex-list

0 commit comments

Comments
 (0)