Skip to content

Commit

Permalink
Use OP_TYPE_IS_COP_NN() in various *.c files
Browse files Browse the repository at this point in the history
  • Loading branch information
leonerd committed Nov 19, 2024
1 parent 6f2dd74 commit 7537474
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
3 changes: 1 addition & 2 deletions gv.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,7 @@ Perl_gv_init_pvn(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, U32 flag
isGV_with_GP_on(gv);

if (really_sub && !CvISXSUB(has_constant) && CvSTART(has_constant)
&& ( CvSTART(has_constant)->op_type == OP_NEXTSTATE
|| CvSTART(has_constant)->op_type == OP_DBSTATE))
&& (OP_TYPE_IS_COP_NN(CvSTART(has_constant))))
PL_curcop = (COP *)CvSTART(has_constant);
GvGP_set(gv, Perl_newGP(aTHX_ gv));
PL_curcop = old;
Expand Down
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_NN(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_NN(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_NN(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_NN(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_NN(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_NN(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_NN(p->op_next)
&& count < OPpPADRANGE_COUNTMASK
&& base + count == p->op_targ
) {
Expand Down
4 changes: 2 additions & 2 deletions pp_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3034,7 +3034,7 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, U32 flags, OP **opstac
OP * const kid1 = cUNOPo->op_first;
/* First try all the kids at this level, since that's likeliest. */
for (kid = cUNOPo->op_first; kid; kid = OpSIBLING(kid)) {
if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) {
if (OP_TYPE_IS_COP_NN(kid)) {
STRLEN kid_label_len;
U32 kid_label_flags;
const char *kid_label = CopLABEL_len_flags(kCOP,
Expand All @@ -3057,7 +3057,7 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, U32 flags, OP **opstac
bool first_kid_of_binary = FALSE;
if (kid == PL_lastgotoprobe)
continue;
if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) {
if (OP_TYPE_IS_COP_NN(kid)) {
if (ops == opstack)
*ops++ = kid;
else if (ops[-1] != UNENTERABLE
Expand Down
3 changes: 1 addition & 2 deletions regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -8317,8 +8317,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
}

if (o->op_type != OP_STUB) {
assert( o->op_type == OP_NEXTSTATE
|| o->op_type == OP_DBSTATE
assert(OP_TYPE_IS_COP_NN(o)
|| (o->op_type == OP_NULL
&& ( o->op_targ == OP_NEXTSTATE
|| o->op_targ == OP_DBSTATE
Expand Down

0 comments on commit 7537474

Please sign in to comment.