summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-10-01 19:29:50 +0000
committerNicholas Clark <nick@ccl4.org>2006-10-01 19:29:50 +0000
commitf0a78170a1cd45c5019f6c77288041aa0767e0ff (patch)
treed74d0904fb4521767ac7e7a1616a1636dbb3ae6a /pp_sys.c
parent135a59c2f92f027eb9590c57b576fc883a7d53aa (diff)
downloadperl-f0a78170a1cd45c5019f6c77288041aa0767e0ff.tar.gz
In pp_binmode, call mode_from_discipline() once and remember the result.
p4raw-id: //depot/perl@28910
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 95914106ba..cdc9385967 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -766,22 +766,23 @@ PP(pp_binmode)
}
PUTBACK;
- if (PerlIO_binmode(aTHX_ fp,IoTYPE(io),mode_from_discipline(discp),
- (discp) ? SvPV_nolen_const(discp) : NULL)) {
- if (IoOFP(io) && IoOFP(io) != IoIFP(io)) {
- if (!PerlIO_binmode(aTHX_ IoOFP(io),IoTYPE(io),
- mode_from_discipline(discp),
- (discp) ? SvPV_nolen_const(discp) : NULL)) {
- SPAGAIN;
- RETPUSHUNDEF;
- }
+ {
+ const int mode = mode_from_discipline(discp);
+ const char *const d = (discp ? SvPV_nolen_const(discp) : NULL);
+ if (PerlIO_binmode(aTHX_ fp, IoTYPE(io), mode, d)) {
+ if (IoOFP(io) && IoOFP(io) != IoIFP(io)) {
+ if (!PerlIO_binmode(aTHX_ IoOFP(io), IoTYPE(io), mode, d)) {
+ SPAGAIN;
+ RETPUSHUNDEF;
+ }
+ }
+ SPAGAIN;
+ RETPUSHYES;
+ }
+ else {
+ SPAGAIN;
+ RETPUSHUNDEF;
}
- SPAGAIN;
- RETPUSHYES;
- }
- else {
- SPAGAIN;
- RETPUSHUNDEF;
}
}