This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_sys.c: Optimize out a call to PerlIO_get_cnt
authorNiels Thykier <niels@thykier.net>
Sat, 22 Mar 2014 14:54:41 +0000 (15:54 +0100)
committerTony Cook <tony@develop-help.com>
Wed, 28 May 2014 03:29:06 +0000 (13:29 +1000)
If PerlIO_getc returns EOF, PerlIO_get_cnt is not going to return a
positive value all of a sudden.

Signed-off-by: Niels Thykier <niels@thykier.net>
pp_sys.c

index 0541a72..671a9c0 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3322,9 +3322,10 @@ PP(pp_fttext)
                i = PerlIO_getc(IoIFP(io));
                if (i != EOF)
                    (void)PerlIO_ungetc(IoIFP(io),i);
+                else
+                    /* null file is anything */
+                    FT_RETURNYES;
            }
-           if (PerlIO_get_cnt(IoIFP(io)) <= 0) /* null file is anything */
-               FT_RETURNYES;
            len = PerlIO_get_bufsiz(IoIFP(io));
            s = (STDCHAR *) PerlIO_get_base(IoIFP(io));
            /* sfio can have large buffers - limit to 512 */