Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Optimize out a call to PerlIO_get_cnt in pp_fttext #13686

Closed
p5pRT opened this issue Mar 22, 2014 · 8 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Mar 22, 2014

Migrated from rt.perl.org#121489 (status was 'resolved')

Searchable as RT121489$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Mar 22, 2014

From @nthykier

Created by @nthykier

Perl Info

Flags:
    category=core
    severity=wishlist
    Type=Patch
    PatchStatus=HasPatch

Site configuration information for perl 5.19.11:

Configured by Niels Thykier at Sat Mar 22 15:13:03 UTC 2014.

Summary of my perl5 (revision 5 version 19 subversion 11) configuration:
  Derived from: 
  Platform:
    osname=linux, osvers=3.13-1-amd64, archname=x86_64-linux
    uname='linux mangetsu 3.13-1-amd64 #1 smp debian 3.13.5-1 (2014-03-04) x86_64 gnulinux '
    config_args='-des -Dusedevel'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.8.2', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.18.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.18'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    uncommitted-changes


@INC for perl 5.19.11:
    lib
    /usr/local/lib/perl5/site_perl/5.19.11/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.19.11
    /usr/local/lib/perl5/5.19.11/x86_64-linux
    /usr/local/lib/perl5/5.19.11
    .


Environment for perl 5.19.11:
    LANG=C
    LANGUAGE=en_GB:en
    LC_ALL=C
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Mar 22, 2014

From @nthykier

0001-pp_sys.c-Optimize-out-a-call-to-PerlIO_get_cnt.patch
From f7894fadda3f53bccbfb9beb64476389311253c8 Mon Sep 17 00:00:00 2001
From: Niels Thykier <niels@thykier.net>
Date: Sat, 22 Mar 2014 15:54:41 +0100
Subject: [PATCH] pp_sys.c: Optimize out a call to PerlIO_get_cnt

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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pp_sys.c b/pp_sys.c
index 9f97177..07a0941 100644
--- 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 */
-- 
1.9.0

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Mar 22, 2014

From @khwilliamson

On 03/22/2014 09​:51 AM, niels@​thykier.net (via RT) wrote​:

# New Ticket Created by niels@​thykier.net
# Please include the string​: [perl #121489]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121489 >

This is a bug report for perl from niels@​thykier.net,
generated with the help of perlbug 1.40 running under perl 5.19.11.

Thanks!

I will apply this in 5.21 after the code base reopens for general
patches, unless there is objection in the meantime

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Mar 22, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Mar 24, 2014

From @nwc10

On Sat, Mar 22, 2014 at 11​:47​:01AM -0600, Karl Williamson wrote​:

On 03/22/2014 09​:51 AM, niels@​thykier.net (via RT) wrote​:

This is a bug report for perl from niels@​thykier.net,
generated with the help of perlbug 1.40 running under perl 5.19.11.

Thanks!

I will apply this in 5.21 after the code base reopens for general
patches, unless there is objection in the meantime

I added it to the "5.21.1 blockers ticket"
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121332
on the assumption that the purpose of that ticket is to avoid forgetting
things like this.

Nicholas Clark

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Mar 24, 2014

From @nthykier

On 2014-03-22 18​:46, karl williamson via RT wrote​:

On 03/22/2014 09​:51 AM, niels@​thykier.net (via RT) wrote​:

# New Ticket Created by niels@​thykier.net
# Please include the string​: [perl #121489]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121489 >

This is a bug report for perl from niels@​thykier.net,
generated with the help of perlbug 1.40 running under perl 5.19.11.

Thanks!

I will apply this in 5.21 after the code base reopens for general
patches, unless there is objection in the meantime

Thanks, looking forward to it. :)

~Niels

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented May 28, 2014

From @tonycoz

On Sat Mar 22 08​:51​:25 2014, niels@​thykier.net wrote​:

This is a bug report for perl from niels@​thykier.net,
generated with the help of perlbug 1.40 running under perl 5.19.11.

Thanks, applied as bd47baf.

Tony

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented May 28, 2014

@tonycoz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.