Skip to content

Commit 6a8ca91

Browse files
committed
Add OpSIBLING_nocheck() and use it
This macro is to be used when it is known that things are sane, and avoids a conditional. And it avoids warnings that a future commit would otherwise introduce.
1 parent 6d3141b commit 6a8ca91

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

op.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ Perl_scalar(pTHX_ OP *o)
20912091
kid = cLISTOPo->op_first;
20922092
kid = OpSIBLING(kid); /* get past pushmark */
20932093
assert(OpSIBLING(kid));
2094-
name = op_varname(OpSIBLING(kid));
2094+
name = op_varname(OpSIBLING_nocheck(kid));
20952095
if (!name) /* XS module fiddling with the op tree */
20962096
break;
20972097
warn_elem_scalar_context(kid, name, o->op_type == OP_KVHSLICE, false);

op.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,8 @@ C<sib> is non-null. For a higher-level interface, see C<L</op_sibling_splice>>.
10991099
#define OP_IS_STAT(op) (OP_IS_FILETEST(op) || (op) == OP_LSTAT || (op) == OP_STAT)
11001100

11011101
#define OpHAS_SIBLING(o) (cBOOL((o)->op_moresib))
1102-
#define OpSIBLING(o) ((o)->op_moresib ? (o)->op_sibparent : NULL)
1102+
#define OpSIBLING_nocheck(o) ((o)->op_sibparent)
1103+
#define OpSIBLING(o) (OpHAS_SIBLING(o) ? OpSIBLING_nocheck(o) : NULL)
11031104
#define OpMORESIB_set(o, sib) ((o)->op_moresib = 1, (o)->op_sibparent = (sib))
11041105
#define OpLASTSIB_set(o, parent) \
11051106
((o)->op_moresib = 0, (o)->op_sibparent = (parent))

peep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ S_scalar_slice_warning(pTHX_ const OP *o)
7777
return;
7878

7979
assert(OpSIBLING(kid));
80-
name = op_varname(OpSIBLING(kid));
80+
name = op_varname(OpSIBLING_nocheck(kid));
8181
if (!name) /* XS module fiddling with the op tree */
8282
return;
8383
warn_elem_scalar_context(kid, name, is_hash, true);
@@ -754,7 +754,7 @@ S_maybe_multiconcat(pTHX_ OP *o)
754754
lastkidop = cLISTOPx(topop)->op_last;
755755
kid = cUNOPx(topop)->op_first; /* pushmark */
756756
op_null(kid);
757-
op_null(OpSIBLING(kid)); /* const */
757+
op_null(OpSIBLING_nocheck(kid)); /* const */
758758
if (o != topop) {
759759
kid = op_sibling_splice(topop, NULL, -1, NULL); /* cut all args */
760760
op_sibling_splice(o, NULL, 0, kid); /* and attach to o */

0 commit comments

Comments
 (0)