Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions peep.c
Original file line number Diff line number Diff line change
Expand Up @@ -3124,6 +3124,43 @@ Perl_rpeep(pTHX_ OP *o)

case OP_PUSHMARK:

/* Given
pushmark
null
something_else
Take out the null wherever possible.
*/
while (OP_TYPE_IS(o->op_next, OP_NULL)) {
OP* next = o->op_next;
o->op_next = next->op_next;
if (OpSIBLING(o) == next &&
next->op_moresib &&
!(next->op_flags & OPf_KIDS)) {
op_sibling_splice(NULL, o, 1, NULL);
op_free(next);
}
}

/* Given
list (in scalar context)
pushmark
something
The pushmark & list OPs are unnecessary.
*/

{
OP *nn = o->op_next->op_next;
if (OP_TYPE_IS(nn, OP_LIST) &&
((nn->op_flags & OPf_WANT) == OPf_WANT_SCALAR) ) {
if (oldop)
oldop->op_next = o->op_next;
o->op_next->op_next = nn->op_next;
op_null(nn);
op_null(o);
oldop = NULL; oldoldop = NULL;
}
}

/* Given
5 repeat/DOLIST
3 ex-list
Expand Down
Loading