summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-01-02 20:56:21 +0000
committerNicholas Clark <nick@ccl4.org>2011-01-02 20:56:21 +0000
commit9c9f25b8ce09796ec5e5e4e5c76f43506c223a8f (patch)
tree0a350bd0d84bb3068db4da380354fca0ac235de4 /doio.c
parent9426e1a55981168c83a030df9bce5e0b46586581 (diff)
downloadperl-9c9f25b8ce09796ec5e5e4e5c76f43506c223a8f.tar.gz
GvIO(gv) returns NULL for a NULL gv, so refactor to take advantage of this.
Simplify tests of !gv || !io to just !io, avoid calling GvIO(gv) more than once, and where possible initialise io at declaration time, to allow it to be const.
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/doio.c b/doio.c
index 24af26360c..73ae83a763 100644
--- a/doio.c
+++ b/doio.c
@@ -1034,12 +1034,12 @@ Off_t
Perl_do_tell(pTHX_ GV *gv)
{
dVAR;
- register IO *io = NULL;
+ IO *const io = GvIO(gv);
register PerlIO *fp;
PERL_ARGS_ASSERT_DO_TELL;
- if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) {
+ if (io && (fp = IoIFP(io))) {
#ifdef ULTRIX_STDIO_BOTCH
if (PerlIO_eof(fp))
(void)PerlIO_seek(fp, 0L, 2); /* ultrix 1.2 workaround */
@@ -1055,10 +1055,10 @@ bool
Perl_do_seek(pTHX_ GV *gv, Off_t pos, int whence)
{
dVAR;
- register IO *io = NULL;
+ IO *const io = GvIO(gv);
register PerlIO *fp;
- if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) {
+ if (io && (fp = IoIFP(io))) {
#ifdef ULTRIX_STDIO_BOTCH
if (PerlIO_eof(fp))
(void)PerlIO_seek(fp, 0L, 2); /* ultrix 1.2 workaround */
@@ -1074,12 +1074,12 @@ Off_t
Perl_do_sysseek(pTHX_ GV *gv, Off_t pos, int whence)
{
dVAR;
- register IO *io = NULL;
+ IO *const io = GvIO(gv);
register PerlIO *fp;
PERL_ARGS_ASSERT_DO_SYSSEEK;
- if (gv && (io = GvIO(gv)) && (fp = IoIFP(io)))
+ if (io && (fp = IoIFP(io)))
return PerlLIO_lseek(PerlIO_fileno(fp), pos, whence);
report_evil_fh(gv);
SETERRNO(EBADF,RMS_IFI);