summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2005-07-13 00:21:13 +0000
committerDave Mitchell <davem@fdisolutions.com>2005-07-13 00:21:13 +0000
commit041457d90dbb6fb79a72c7a8462f01423f2daa09 (patch)
tree5393e1e2a48eb57f050aa85b76a30b7f9f198257 /doio.c
parente352bcff231c07cf21f07ae801f374a3da3229ed (diff)
downloadperl-041457d90dbb6fb79a72c7a8462f01423f2daa09.tar.gz
make the expensive ckWARN() be called as late as possible
reorganise if (ckWARN(FOO) && should_not_happen_condition) to if (should_not_happen_condition && ckWARN(FOO)) p4raw-id: //depot/perl@25129
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/doio.c b/doio.c
index b105845e84..4d7d19b955 100644
--- a/doio.c
+++ b/doio.c
@@ -566,7 +566,9 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
}
}
if (!fp) {
- if (ckWARN(WARN_NEWLINE) && IoTYPE(io) == IoTYPE_RDONLY && strchr(name, '\n'))
+ if (IoTYPE(io) == IoTYPE_RDONLY && strchr(name, '\n')
+ && ckWARN(WARN_NEWLINE)
+ )
Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "open");
goto say_false;
}
@@ -1079,7 +1081,7 @@ Perl_do_eof(pTHX_ GV *gv)
if (!io)
return TRUE;
- else if (ckWARN(WARN_IO) && (IoTYPE(io) == IoTYPE_WRONLY))
+ else if ((IoTYPE(io) == IoTYPE_WRONLY) && ckWARN(WARN_IO))
report_evil_fh(gv, io, OP_phoney_OUTPUT_ONLY);
while (IoIFP(io)) {
@@ -1392,7 +1394,7 @@ Perl_my_stat(pTHX)
s = SvPVX_const(PL_statname); /* s now NUL-terminated */
PL_laststype = OP_STAT;
PL_laststatval = PerlLIO_stat(s, &PL_statcache);
- if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(s, '\n'))
+ if (PL_laststatval < 0 && strchr(s, '\n') && ckWARN(WARN_NEWLINE))
Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "stat");
return PL_laststatval;
}
@@ -1418,8 +1420,8 @@ Perl_my_lstat(pTHX)
return (PL_laststatval = -1);
}
}
- else if (ckWARN(WARN_IO) && PL_laststype != OP_LSTAT
- && (PL_op->op_private & OPpFT_STACKED))
+ else if (PL_laststype != OP_LSTAT
+ && (PL_op->op_private & OPpFT_STACKED) && ckWARN(WARN_IO))
Perl_croak(aTHX_ no_prev_lstat);
PL_laststype = OP_LSTAT;