Skip to content

Commit

Permalink
Use OP_TYPE_IS_COP() in op.c and peep.c
Browse files Browse the repository at this point in the history
  • Loading branch information
leonerd committed Nov 18, 2024
1 parent 04de8ee commit 06a01bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
10 changes: 4 additions & 6 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -2136,8 +2136,7 @@ Perl_scalarvoid(pTHX_ OP *arg)
const char* useless = NULL;
OP * next_kid = NULL;

if (o->op_type == OP_NEXTSTATE
|| o->op_type == OP_DBSTATE
if (OP_TYPE_IS_COP(o)
|| (o->op_type == OP_NULL && (o->op_targ == OP_NEXTSTATE
|| o->op_targ == OP_DBSTATE)))
PL_curcop = (COP*)o; /* for warning below */
Expand Down Expand Up @@ -4516,13 +4515,12 @@ Perl_op_scope(pTHX_ OP *o)
OP *kid;
OpTYPE_set(o, OP_SCOPE);
kid = cLISTOPo->op_first;
if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) {
if (OP_TYPE_IS_COP(kid)) {
op_null(kid);

/* The following deals with things like 'do {1 for 1}' */
kid = OpSIBLING(kid);
if (kid &&
(kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE))
if (kid && OP_TYPE_IS_COP(kid))
op_null(kid);
}
}
Expand All @@ -4538,7 +4536,7 @@ Perl_op_unscope(pTHX_ OP *o)
if (o && o->op_type == OP_LINESEQ) {
OP *kid = cLISTOPo->op_first;
for(; kid; kid = OpSIBLING(kid))
if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE)
if (OP_TYPE_IS_COP(kid))
op_null(kid);
}
return o;
Expand Down
10 changes: 3 additions & 7 deletions peep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,9 +1253,7 @@ S_finalize_op(pTHX_ OP* o)
case OP_EXEC:
if (OpHAS_SIBLING(o)) {
OP *sib = OpSIBLING(o);
if (( sib->op_type == OP_NEXTSTATE || sib->op_type == OP_DBSTATE)
&& ckWARN(WARN_EXEC)
&& OpHAS_SIBLING(sib))
if (OP_TYPE_IS_COP(sib) && ckWARN(WARN_EXEC) && OpHAS_SIBLING(sib))
{
const OPCODE type = OpSIBLING(sib)->op_type;
if (type != OP_EXIT && type != OP_WARN && type != OP_DIE) {
Expand Down Expand Up @@ -3343,8 +3341,7 @@ Perl_rpeep(pTHX_ OP *o)
) {
U8 old_count;
assert(oldoldop->op_next == oldop);
assert( oldop->op_type == OP_NEXTSTATE
|| oldop->op_type == OP_DBSTATE);
assert(OP_TYPE_IS_COP(oldop));
assert(oldop->op_next == o);

old_count
Expand Down Expand Up @@ -3379,8 +3376,7 @@ Perl_rpeep(pTHX_ OP *o)
&& (p->op_private & OPpLVAL_INTRO) == intro
&& !(p->op_private & ~OPpLVAL_INTRO)
&& p->op_next
&& ( p->op_next->op_type == OP_NEXTSTATE
|| p->op_next->op_type == OP_DBSTATE)
&& OP_TYPE_IS_COP(p)
&& count < OPpPADRANGE_COUNTMASK
&& base + count == p->op_targ
) {
Expand Down

0 comments on commit 06a01bd

Please sign in to comment.