From: Nicholas Clark <nick@ccl4.org>
Date: Sun, 1 Oct 2006 19:29:50 +0000 (+0000)
Subject: In pp_binmode, call mode_from_discipline() once and remember the result.
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f0a78170a1cd45c5019f6c77288041aa0767e0ff;p=p5sagit%2Fp5-mst-13.2.git

In pp_binmode, call mode_from_discipline() once and remember the result.

p4raw-id: //depot/perl@28910
---

diff --git a/pp_sys.c b/pp_sys.c
index 9591410..cdc9385 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;
     }
 }