From c564b489757973ad664254ae00cf16880e1f7db5 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Sat, 1 Mar 2014 22:00:29 +0100 Subject: In Perl_do_openn(), move {in,out}_{raw,crlf} into the !as_raw block. These 4 variables are only needed there, so by moving them into the block we save doing unneeded work for the as_raw case (ie sysopen), and as a side effect make the function a bit clearer. --- doio.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doio.c b/doio.c index bdff84ca1e..da46367ad1 100644 --- a/doio.c +++ b/doio.c @@ -76,7 +76,6 @@ Perl_do_openn(pTHX_ GV *gv, const char *oname, I32 len, int as_raw, int fd; int result; bool was_fdopen = FALSE; - bool in_raw = 0, in_crlf = 0, out_raw = 0, out_crlf = 0; char *type = NULL; char mode[PERL_MODE_MAX]; /* file mode ("r\0", "rb\0", "ab\0" etc.) */ SV *namesv; @@ -86,16 +85,6 @@ Perl_do_openn(pTHX_ GV *gv, const char *oname, I32 len, int as_raw, Zero(mode,sizeof(mode),char); PL_forkprocess = 1; /* assume true if no fork */ - /* Collect default raw/crlf info from the op */ - if (PL_op && PL_op->op_type == OP_OPEN) { - /* set up IO layers */ - const U8 flags = PL_op->op_private; - in_raw = (flags & OPpOPEN_IN_RAW); - in_crlf = (flags & OPpOPEN_IN_CRLF); - out_raw = (flags & OPpOPEN_OUT_RAW); - out_crlf = (flags & OPpOPEN_OUT_CRLF); - } - /* If currently open - close before we re-open */ if (IoIFP(io)) { fd = PerlIO_fileno(IoIFP(io)); @@ -194,6 +183,17 @@ Perl_do_openn(pTHX_ GV *gv, const char *oname, I32 len, int as_raw, STRLEN olen = len; char *tend; int dodup = 0; + bool in_raw = 0, in_crlf = 0, out_raw = 0, out_crlf = 0; + + /* Collect default raw/crlf info from the op */ + if (PL_op && PL_op->op_type == OP_OPEN) { + /* set up IO layers */ + const U8 flags = PL_op->op_private; + in_raw = (flags & OPpOPEN_IN_RAW); + in_crlf = (flags & OPpOPEN_IN_CRLF); + out_raw = (flags & OPpOPEN_OUT_RAW); + out_crlf = (flags & OPpOPEN_OUT_CRLF); + } type = savepvn(oname, len); tend = type+len; -- cgit v1.2.1