diff options
author | Nicholas Clark <nick@ccl4.org> | 2014-03-01 22:00:29 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2014-03-19 10:57:52 +0100 |
commit | c564b489757973ad664254ae00cf16880e1f7db5 (patch) | |
tree | 2b60610e5f1c9263f5eef7cb7a097e027a1389ba /doio.c | |
parent | 0c9de5b7970eafe06ebc3a92f5f24b972581372d (diff) | |
download | perl-c564b489757973ad664254ae00cf16880e1f7db5.tar.gz |
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.
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -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; |