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] Cwd.pm, dont repeatedly access magic %ENV vars #14825

Closed
p5pRT opened this issue Jul 29, 2015 · 9 comments
Closed

[PATCH] Cwd.pm, dont repeatedly access magic %ENV vars #14825

p5pRT opened this issue Jul 29, 2015 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 29, 2015

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

Searchable as RT125712$

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From @bulk88

Created by @bulk88

See attached patch.

Perl Info

Flags:
         category=core
         severity=low

Site configuration information for perl 5.23.0:

Configured by Owner at Mon Jun 29 03:16:56 2015.

Summary of my perl5 (revision 5 version 23 subversion 0) configuration:
       Derived from: 63602a3fc27a417daf3c532b6a11ae6eba2a072a
       Platform:
         osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
         uname=''
         config_args='undef'
         hint=recommended, useposix=true, d_sigaction=undef
         useithreads=define, usemultiplicity=define
         use64bitint=undef, use64bitall=undef, uselongdouble=undef
         usemymalloc=n, bincompat5005=undef
       Compiler:
         cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL -DWIN32
-D_CONSOLE -DNO_STRICT  -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -D_USE_32BIT_TIME_T',
         optimize='-O1 -MD -Zi -DNDEBUG -GL',
         cppflags='-DWIN32'
         ccversion='13.10.6030', gccversion='', gccosandvers=''
         intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234,
doublekind=3
         d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8,
longdblkind=0
         ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='__int64', lseeksize=8
         alignbytes=8, prototype=define
       Linker and Libraries:
         ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
-ltcg 		-libpath:"c:\perl\lib\CORE" 		-machine:x86'
         libpth=\lib
         libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
         perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
         libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl523.lib
         gnulibc_version=''
       Dynamic Linking:
         dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
         cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf -ltcg 		-libpath:"c:\perl\lib\CORE" 		-machine:x86'

Locally applied patches:
         uncommitted-changes


@INC for perl 5.23.0:
         C:/perl521/srcnewb4opt/lib
         .


Environment for perl 5.23.0:
         HOME (unset)
         LANG (unset)
         LANGUAGE (unset)
         LD_LIBRARY_PATH (unset)
         LOGDIR (unset)
         PATH=C:\sperl\c\bin;C:\WINDOWS\system32;C:\Program Files\Microsoft
Visual Studio .NET 2003\Vc7\bin;C:\Program Files\Microsoft Visual Studio
.NET 2003\Common7\IDE;C:\WINDOWS;C:\Program Files\Git\cmd;C:\Program
Files\Microsoft Visual Studio .NET 2003\Common7\Tools\bin;C:\perl\bin
         PERL_BADLANG (unset)
         PERL_JSON_BACKEND=Cpanel::JSON::XS
         PERL_YAML_BACKEND=YAML
         SHELL (unset)








@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From @bulk88

0001-Cwd.pm-dont-repeatedly-access-magic-ENV-vars.patch
From f6c71435312084daaa30ecc092ad3853980634a5 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Tue, 28 Jul 2015 23:08:38 -0400
Subject: [PATCH] Cwd.pm, dont repeatedly access magic %ENV vars

%ENV is magic/tied, a lexical is faster than calling out to magic APIs
with gets and sets (or checks for them). Less glob and hash lookups too.

Return the lexical instead of the magic var so there isn't a search for
magic from pp_leavesub's sv_mortalcopy. Even though env mg vtable doesn't
have a getter or GMAGIC, SvVSTRING_mg executes mg_find for random, get
and set magic inside Perl_sv_setsv_flags.
---
 dist/PathTools/Cwd.pm |   51 ++++++++++++++++++++++++++----------------------
 1 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/dist/PathTools/Cwd.pm b/dist/PathTools/Cwd.pm
index 49cc4c1..0765de4 100644
--- a/dist/PathTools/Cwd.pm
+++ b/dist/PathTools/Cwd.pm
@@ -3,7 +3,7 @@ use strict;
 use Exporter;
 use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 my $xs_version = $VERSION;
 $VERSION =~ tr/_//;
 
@@ -600,20 +600,23 @@ sub _vms_abs_path {
 }
 
 sub _os2_cwd {
-    $ENV{'PWD'} = `cmd /c cd`;
-    chomp $ENV{'PWD'};
-    $ENV{'PWD'} =~ s:\\:/:g ;
-    return $ENV{'PWD'};
+    my $pwd = `cmd /c cd`;
+    chomp $pwd;
+    $pwd =~ s:\\:/:g ;
+    $ENV{'PWD'} = $pwd;
+    return $pwd;
 }
 
 sub _win32_cwd_simple {
-    $ENV{'PWD'} = `cd`;
-    chomp $ENV{'PWD'};
-    $ENV{'PWD'} =~ s:\\:/:g ;
-    return $ENV{'PWD'};
+    my $pwd = `cd`;
+    chomp $pwd;
+    $pwd =~ s:\\:/:g ;
+    $ENV{'PWD'} = $pwd;
+    return $pwd;
 }
 
 sub _win32_cwd {
+    my $pwd;
     # Need to avoid taking any sort of reference to the typeglob or the code in
     # the optree, so that this tests the runtime state of things, as the
     # ExtUtils::MakeMaker tests for "miniperl" need to be able to fake things at
@@ -622,35 +625,38 @@ sub _win32_cwd {
     # problems (for reasons that we haven't been able to get to the bottom of -
     # rt.cpan.org #56225)
     if (*{$DynaLoader::{boot_DynaLoader}}{CODE}) {
-	$ENV{'PWD'} = Win32::GetCwd();
+	$pwd = Win32::GetCwd();
     }
     else { # miniperl
-	chomp($ENV{'PWD'} = `cd`);
+	chomp($pwd = `cd`);
     }
-    $ENV{'PWD'} =~ s:\\:/:g ;
-    return $ENV{'PWD'};
+    $pwd =~ s:\\:/:g ;
+    $ENV{'PWD'} = $pwd;
+    return $pwd;
 }
 
 *_NT_cwd = defined &Win32::GetCwd ? \&_win32_cwd : \&_win32_cwd_simple;
 
 sub _dos_cwd {
+    my $pwd;
     if (!defined &Dos::GetCwd) {
-        $ENV{'PWD'} = `command /c cd`;
-        chomp $ENV{'PWD'};
-        $ENV{'PWD'} =~ s:\\:/:g ;
+        chomp($pwd = `command /c cd`);
+        $pwd =~ s:\\:/:g ;
     } else {
-        $ENV{'PWD'} = Dos::GetCwd();
+        $pwd = Dos::GetCwd();
     }
-    return $ENV{'PWD'};
+    $ENV{'PWD'} = $pwd;
+    return $pwd;
 }
 
 sub _qnx_cwd {
 	local $ENV{PATH} = '';
 	local $ENV{CDPATH} = '';
 	local $ENV{ENV} = '';
-    $ENV{'PWD'} = `/usr/bin/fullpath -t`;
-    chomp $ENV{'PWD'};
-    return $ENV{'PWD'};
+    my $pwd = `/usr/bin/fullpath -t`;
+    chomp $pwd;
+    $ENV{'PWD'} = $pwd;
+    return $pwd;
 }
 
 sub _qnx_abs_path {
@@ -669,8 +675,7 @@ sub _qnx_abs_path {
 }
 
 sub _epoc_cwd {
-    $ENV{'PWD'} = EPOC::getcwd();
-    return $ENV{'PWD'};
+    return $ENV{'PWD'} = EPOC::getcwd();
 }
 
 
-- 
1.7.9.msysgit.0

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From @bulk88

On Tue Jul 28 21​:24​:24 2015, bulk88 wrote​:

This is a bug report for perl from bulk88@​hotmail.com,
generated with the help of perlbug 1.40 running under perl 5.23.0.

-----------------------------------------------------------------
[Please describe your issue here]

See attached patch.

First patch had test failures due to incorrect version bumping. New attached.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From @bulk88

0001-Cwd.pm-dont-repeatedly-access-magic-ENV-vars.patch
From fd9b3bec5abe588e5799e86968f834da44a84320 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Wed, 29 Jul 2015 09:54:51 -0400
Subject: [PATCH] Cwd.pm, dont repeatedly access magic %ENV vars

%ENV is magic/tied, a lexical is faster than calling out to magic APIs
with gets and sets (or checks for them). Less glob and hash lookups too.

Return the lexical instead of the magic var so there isn't a search for
magic from pp_leavesub's sv_mortalcopy. Even though env mg vtable doesn't
have a getter or GMAGIC, SvVSTRING_mg executes mg_find for random, get
and set magic inside Perl_sv_setsv_flags.
---
 dist/PathTools/Cwd.pm                     |   51 ++++++++++++++++-------------
 dist/PathTools/lib/File/Spec.pm           |    2 +-
 dist/PathTools/lib/File/Spec/Cygwin.pm    |    2 +-
 dist/PathTools/lib/File/Spec/Epoc.pm      |    2 +-
 dist/PathTools/lib/File/Spec/Functions.pm |    2 +-
 dist/PathTools/lib/File/Spec/Mac.pm       |    2 +-
 dist/PathTools/lib/File/Spec/OS2.pm       |    2 +-
 dist/PathTools/lib/File/Spec/Unix.pm      |    2 +-
 dist/PathTools/lib/File/Spec/VMS.pm       |    2 +-
 dist/PathTools/lib/File/Spec/Win32.pm     |    2 +-
 10 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/dist/PathTools/Cwd.pm b/dist/PathTools/Cwd.pm
index 49cc4c1..0765de4 100644
--- a/dist/PathTools/Cwd.pm
+++ b/dist/PathTools/Cwd.pm
@@ -3,7 +3,7 @@ use strict;
 use Exporter;
 use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 my $xs_version = $VERSION;
 $VERSION =~ tr/_//;
 
@@ -600,20 +600,23 @@ sub _vms_abs_path {
 }
 
 sub _os2_cwd {
-    $ENV{'PWD'} = `cmd /c cd`;
-    chomp $ENV{'PWD'};
-    $ENV{'PWD'} =~ s:\\:/:g ;
-    return $ENV{'PWD'};
+    my $pwd = `cmd /c cd`;
+    chomp $pwd;
+    $pwd =~ s:\\:/:g ;
+    $ENV{'PWD'} = $pwd;
+    return $pwd;
 }
 
 sub _win32_cwd_simple {
-    $ENV{'PWD'} = `cd`;
-    chomp $ENV{'PWD'};
-    $ENV{'PWD'} =~ s:\\:/:g ;
-    return $ENV{'PWD'};
+    my $pwd = `cd`;
+    chomp $pwd;
+    $pwd =~ s:\\:/:g ;
+    $ENV{'PWD'} = $pwd;
+    return $pwd;
 }
 
 sub _win32_cwd {
+    my $pwd;
     # Need to avoid taking any sort of reference to the typeglob or the code in
     # the optree, so that this tests the runtime state of things, as the
     # ExtUtils::MakeMaker tests for "miniperl" need to be able to fake things at
@@ -622,35 +625,38 @@ sub _win32_cwd {
     # problems (for reasons that we haven't been able to get to the bottom of -
     # rt.cpan.org #56225)
     if (*{$DynaLoader::{boot_DynaLoader}}{CODE}) {
-	$ENV{'PWD'} = Win32::GetCwd();
+	$pwd = Win32::GetCwd();
     }
     else { # miniperl
-	chomp($ENV{'PWD'} = `cd`);
+	chomp($pwd = `cd`);
     }
-    $ENV{'PWD'} =~ s:\\:/:g ;
-    return $ENV{'PWD'};
+    $pwd =~ s:\\:/:g ;
+    $ENV{'PWD'} = $pwd;
+    return $pwd;
 }
 
 *_NT_cwd = defined &Win32::GetCwd ? \&_win32_cwd : \&_win32_cwd_simple;
 
 sub _dos_cwd {
+    my $pwd;
     if (!defined &Dos::GetCwd) {
-        $ENV{'PWD'} = `command /c cd`;
-        chomp $ENV{'PWD'};
-        $ENV{'PWD'} =~ s:\\:/:g ;
+        chomp($pwd = `command /c cd`);
+        $pwd =~ s:\\:/:g ;
     } else {
-        $ENV{'PWD'} = Dos::GetCwd();
+        $pwd = Dos::GetCwd();
     }
-    return $ENV{'PWD'};
+    $ENV{'PWD'} = $pwd;
+    return $pwd;
 }
 
 sub _qnx_cwd {
 	local $ENV{PATH} = '';
 	local $ENV{CDPATH} = '';
 	local $ENV{ENV} = '';
-    $ENV{'PWD'} = `/usr/bin/fullpath -t`;
-    chomp $ENV{'PWD'};
-    return $ENV{'PWD'};
+    my $pwd = `/usr/bin/fullpath -t`;
+    chomp $pwd;
+    $ENV{'PWD'} = $pwd;
+    return $pwd;
 }
 
 sub _qnx_abs_path {
@@ -669,8 +675,7 @@ sub _qnx_abs_path {
 }
 
 sub _epoc_cwd {
-    $ENV{'PWD'} = EPOC::getcwd();
-    return $ENV{'PWD'};
+    return $ENV{'PWD'} = EPOC::getcwd();
 }
 
 
diff --git a/dist/PathTools/lib/File/Spec.pm b/dist/PathTools/lib/File/Spec.pm
index 8c77c98..2f35526 100644
--- a/dist/PathTools/lib/File/Spec.pm
+++ b/dist/PathTools/lib/File/Spec.pm
@@ -3,7 +3,7 @@ package File::Spec;
 use strict;
 use vars qw(@ISA $VERSION);
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 $VERSION =~ tr/_//;
 
 my %module = (MacOS   => 'Mac',
diff --git a/dist/PathTools/lib/File/Spec/Cygwin.pm b/dist/PathTools/lib/File/Spec/Cygwin.pm
index 1b77e6a..e5839e9 100644
--- a/dist/PathTools/lib/File/Spec/Cygwin.pm
+++ b/dist/PathTools/lib/File/Spec/Cygwin.pm
@@ -4,7 +4,7 @@ use strict;
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 $VERSION =~ tr/_//;
 
 @ISA = qw(File::Spec::Unix);
diff --git a/dist/PathTools/lib/File/Spec/Epoc.pm b/dist/PathTools/lib/File/Spec/Epoc.pm
index 7bc3867..390a641 100644
--- a/dist/PathTools/lib/File/Spec/Epoc.pm
+++ b/dist/PathTools/lib/File/Spec/Epoc.pm
@@ -3,7 +3,7 @@ package File::Spec::Epoc;
 use strict;
 use vars qw($VERSION @ISA);
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 $VERSION =~ tr/_//;
 
 require File::Spec::Unix;
diff --git a/dist/PathTools/lib/File/Spec/Functions.pm b/dist/PathTools/lib/File/Spec/Functions.pm
index 8eafe24..5c2cec0 100644
--- a/dist/PathTools/lib/File/Spec/Functions.pm
+++ b/dist/PathTools/lib/File/Spec/Functions.pm
@@ -5,7 +5,7 @@ use strict;
 
 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 $VERSION =~ tr/_//;
 
 require Exporter;
diff --git a/dist/PathTools/lib/File/Spec/Mac.pm b/dist/PathTools/lib/File/Spec/Mac.pm
index 02cae14..7cc816f 100644
--- a/dist/PathTools/lib/File/Spec/Mac.pm
+++ b/dist/PathTools/lib/File/Spec/Mac.pm
@@ -4,7 +4,7 @@ use strict;
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 $VERSION =~ tr/_//;
 
 @ISA = qw(File::Spec::Unix);
diff --git a/dist/PathTools/lib/File/Spec/OS2.pm b/dist/PathTools/lib/File/Spec/OS2.pm
index fb8f101..8d3951f 100644
--- a/dist/PathTools/lib/File/Spec/OS2.pm
+++ b/dist/PathTools/lib/File/Spec/OS2.pm
@@ -4,7 +4,7 @@ use strict;
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 $VERSION =~ tr/_//;
 
 @ISA = qw(File::Spec::Unix);
diff --git a/dist/PathTools/lib/File/Spec/Unix.pm b/dist/PathTools/lib/File/Spec/Unix.pm
index f76b29e..48e2b60 100644
--- a/dist/PathTools/lib/File/Spec/Unix.pm
+++ b/dist/PathTools/lib/File/Spec/Unix.pm
@@ -3,7 +3,7 @@ package File::Spec::Unix;
 use strict;
 use vars qw($VERSION);
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 my $xs_version = $VERSION;
 $VERSION =~ tr/_//;
 
diff --git a/dist/PathTools/lib/File/Spec/VMS.pm b/dist/PathTools/lib/File/Spec/VMS.pm
index 254f524..5e4a3b3 100644
--- a/dist/PathTools/lib/File/Spec/VMS.pm
+++ b/dist/PathTools/lib/File/Spec/VMS.pm
@@ -4,7 +4,7 @@ use strict;
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 $VERSION =~ tr/_//;
 
 @ISA = qw(File::Spec::Unix);
diff --git a/dist/PathTools/lib/File/Spec/Win32.pm b/dist/PathTools/lib/File/Spec/Win32.pm
index 53f3854..77e0fed 100644
--- a/dist/PathTools/lib/File/Spec/Win32.pm
+++ b/dist/PathTools/lib/File/Spec/Win32.pm
@@ -5,7 +5,7 @@ use strict;
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '3.56';
+$VERSION = '3.57';
 $VERSION =~ tr/_//;
 
 @ISA = qw(File::Spec::Unix);
-- 
1.7.9.msysgit.0

@p5pRT
Copy link
Author

p5pRT commented Jul 30, 2015

From @tonycoz

On Wed Jul 29 08​:20​:08 2015, bulk88 wrote​:

On Tue Jul 28 21​:24​:24 2015, bulk88 wrote​:

This is a bug report for perl from bulk88@​hotmail.com,
generated with the help of perlbug 1.40 running under perl 5.23.0.

-----------------------------------------------------------------
[Please describe your issue here]

See attached patch.

First patch had test failures due to incorrect version bumping. New
attached.

Thanks, applied as 3480fba.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jul 30, 2015

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

@p5pRT
Copy link
Author

p5pRT commented Jul 30, 2015

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

@p5pRT p5pRT closed this as completed Jul 30, 2015
@p5pRT
Copy link
Author

p5pRT commented Jul 30, 2015

From wuhaoecho@gmail.com

since you change

- $ENV{'PWD'} = EPOC​::getcwd();
- return $ENV{'PWD'};
+ return $ENV{'PWD'} = EPOC​::getcwd();

why not change all

+ $ENV{'PWD'} = $pwd;
+ return $pwd;

to

return $ENV{'PWD'} = $pwd;

?

although there should not be much difference.

Best,

Hao

On Wed, Jul 29, 2015 at 8​:20 AM, bulk88 via RT <perlbug-followup@​perl.org>
wrote​:

On Tue Jul 28 21​:24​:24 2015, bulk88 wrote​:

This is a bug report for perl from bulk88@​hotmail.com,
generated with the help of perlbug 1.40 running under perl 5.23.0.

-----------------------------------------------------------------
[Please describe your issue here]

See attached patch.

First patch had test failures due to incorrect version bumping. New
attached.

--
bulk88 ~ bulk88 at hotmail.com

---
via perlbug​: queue​: perl5 status​: new
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=125712

From fd9b3bec5abe588e5799e86968f834da44a84320 Mon Sep 17 00​:00​:00 2001
From​: Daniel Dragan <bulk88@​hotmail.com>
Date​: Wed, 29 Jul 2015 09​:54​:51 -0400
Subject​: [PATCH] Cwd.pm, dont repeatedly access magic %ENV vars

%ENV is magic/tied, a lexical is faster than calling out to magic APIs
with gets and sets (or checks for them). Less glob and hash lookups too.

Return the lexical instead of the magic var so there isn't a search for
magic from pp_leavesub's sv_mortalcopy. Even though env mg vtable doesn't
have a getter or GMAGIC, SvVSTRING_mg executes mg_find for random, get
and set magic inside Perl_sv_setsv_flags.
---
dist/PathTools/Cwd.pm | 51
++++++++++++++++-------------
dist/PathTools/lib/File/Spec.pm | 2 +-
dist/PathTools/lib/File/Spec/Cygwin.pm | 2 +-
dist/PathTools/lib/File/Spec/Epoc.pm | 2 +-
dist/PathTools/lib/File/Spec/Functions.pm | 2 +-
dist/PathTools/lib/File/Spec/Mac.pm | 2 +-
dist/PathTools/lib/File/Spec/OS2.pm | 2 +-
dist/PathTools/lib/File/Spec/Unix.pm | 2 +-
dist/PathTools/lib/File/Spec/VMS.pm | 2 +-
dist/PathTools/lib/File/Spec/Win32.pm | 2 +-
10 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/dist/PathTools/Cwd.pm b/dist/PathTools/Cwd.pm
index 49cc4c1..0765de4 100644
--- a/dist/PathTools/Cwd.pm
+++ b/dist/PathTools/Cwd.pm
@​@​ -3,7 +3,7 @​@​ use strict;
use Exporter;
use vars qw(@​ISA @​EXPORT @​EXPORT_OK $VERSION);

-$VERSION = '3.56';
+$VERSION = '3.57';
my $xs_version = $VERSION;
$VERSION =~ tr/_//;

@​@​ -600,20 +600,23 @​@​ sub _vms_abs_path {
}

sub _os2_cwd {
- $ENV{'PWD'} = `cmd /c cd`;
- chomp $ENV{'PWD'};
- $ENV{'PWD'} =~ s​:\\​:/​:g ;
- return $ENV{'PWD'};
+ my $pwd = `cmd /c cd`;
+ chomp $pwd;
+ $pwd =~ s​:\\​:/​:g ;
+ $ENV{'PWD'} = $pwd;
+ return $pwd;
}

sub _win32_cwd_simple {
- $ENV{'PWD'} = `cd`;
- chomp $ENV{'PWD'};
- $ENV{'PWD'} =~ s​:\\​:/​:g ;
- return $ENV{'PWD'};
+ my $pwd = `cd`;
+ chomp $pwd;
+ $pwd =~ s​:\\​:/​:g ;
+ $ENV{'PWD'} = $pwd;
+ return $pwd;
}

sub _win32_cwd {
+ my $pwd;
# Need to avoid taking any sort of reference to the typeglob or the
code in
# the optree, so that this tests the runtime state of things, as the
# ExtUtils​::MakeMaker tests for "miniperl" need to be able to fake
things at
@​@​ -622,35 +625,38 @​@​ sub _win32_cwd {
# problems (for reasons that we haven't been able to get to the
bottom of -
# rt.cpan.org #56225)
if (*{$DynaLoader​::{boot_DynaLoader}}{CODE}) {
- $ENV{'PWD'} = Win32​::GetCwd();
+ $pwd = Win32​::GetCwd();
}
else { # miniperl
- chomp($ENV{'PWD'} = `cd`);
+ chomp($pwd = `cd`);
}
- $ENV{'PWD'} =~ s​:\\​:/​:g ;
- return $ENV{'PWD'};
+ $pwd =~ s​:\\​:/​:g ;
+ $ENV{'PWD'} = $pwd;
+ return $pwd;
}

*_NT_cwd = defined &Win32​::GetCwd ? \&_win32_cwd : \&_win32_cwd_simple;

sub _dos_cwd {
+ my $pwd;
if (!defined &Dos​::GetCwd) {
- $ENV{'PWD'} = `command /c cd`;
- chomp $ENV{'PWD'};
- $ENV{'PWD'} =~ s​:\\​:/​:g ;
+ chomp($pwd = `command /c cd`);
+ $pwd =~ s​:\\​:/​:g ;
} else {
- $ENV{'PWD'} = Dos​::GetCwd();
+ $pwd = Dos​::GetCwd();
}
- return $ENV{'PWD'};
+ $ENV{'PWD'} = $pwd;
+ return $pwd;
}

sub _qnx_cwd {
local $ENV{PATH} = '';
local $ENV{CDPATH} = '';
local $ENV{ENV} = '';
- $ENV{'PWD'} = `/usr/bin/fullpath -t`;
- chomp $ENV{'PWD'};
- return $ENV{'PWD'};
+ my $pwd = `/usr/bin/fullpath -t`;
+ chomp $pwd;
+ $ENV{'PWD'} = $pwd;
+ return $pwd;
}

sub _qnx_abs_path {
@​@​ -669,8 +675,7 @​@​ sub _qnx_abs_path {
}

sub _epoc_cwd {
- $ENV{'PWD'} = EPOC​::getcwd();
- return $ENV{'PWD'};
+ return $ENV{'PWD'} = EPOC​::getcwd();
}

diff --git a/dist/PathTools/lib/File/Spec.pm
b/dist/PathTools/lib/File/Spec.pm
index 8c77c98..2f35526 100644
--- a/dist/PathTools/lib/File/Spec.pm
+++ b/dist/PathTools/lib/File/Spec.pm
@​@​ -3,7 +3,7 @​@​ package File​::Spec;
use strict;
use vars qw(@​ISA $VERSION);

-$VERSION = '3.56';
+$VERSION = '3.57';
$VERSION =~ tr/_//;

my %module = (MacOS => 'Mac',
diff --git a/dist/PathTools/lib/File/Spec/Cygwin.pm
b/dist/PathTools/lib/File/Spec/Cygwin.pm
index 1b77e6a..e5839e9 100644
--- a/dist/PathTools/lib/File/Spec/Cygwin.pm
+++ b/dist/PathTools/lib/File/Spec/Cygwin.pm
@​@​ -4,7 +4,7 @​@​ use strict;
use vars qw(@​ISA $VERSION);
require File​::Spec​::Unix;

-$VERSION = '3.56';
+$VERSION = '3.57';
$VERSION =~ tr/_//;

@​ISA = qw(File​::Spec​::Unix);
diff --git a/dist/PathTools/lib/File/Spec/Epoc.pm
b/dist/PathTools/lib/File/Spec/Epoc.pm
index 7bc3867..390a641 100644
--- a/dist/PathTools/lib/File/Spec/Epoc.pm
+++ b/dist/PathTools/lib/File/Spec/Epoc.pm
@​@​ -3,7 +3,7 @​@​ package File​::Spec​::Epoc;
use strict;
use vars qw($VERSION @​ISA);

-$VERSION = '3.56';
+$VERSION = '3.57';
$VERSION =~ tr/_//;

require File​::Spec​::Unix;
diff --git a/dist/PathTools/lib/File/Spec/Functions.pm
b/dist/PathTools/lib/File/Spec/Functions.pm
index 8eafe24..5c2cec0 100644
--- a/dist/PathTools/lib/File/Spec/Functions.pm
+++ b/dist/PathTools/lib/File/Spec/Functions.pm
@​@​ -5,7 +5,7 @​@​ use strict;

use vars qw(@​ISA @​EXPORT @​EXPORT_OK %EXPORT_TAGS $VERSION);

-$VERSION = '3.56';
+$VERSION = '3.57';
$VERSION =~ tr/_//;

require Exporter;
diff --git a/dist/PathTools/lib/File/Spec/Mac.pm
b/dist/PathTools/lib/File/Spec/Mac.pm
index 02cae14..7cc816f 100644
--- a/dist/PathTools/lib/File/Spec/Mac.pm
+++ b/dist/PathTools/lib/File/Spec/Mac.pm
@​@​ -4,7 +4,7 @​@​ use strict;
use vars qw(@​ISA $VERSION);
require File​::Spec​::Unix;

-$VERSION = '3.56';
+$VERSION = '3.57';
$VERSION =~ tr/_//;

@​ISA = qw(File​::Spec​::Unix);
diff --git a/dist/PathTools/lib/File/Spec/OS2.pm
b/dist/PathTools/lib/File/Spec/OS2.pm
index fb8f101..8d3951f 100644
--- a/dist/PathTools/lib/File/Spec/OS2.pm
+++ b/dist/PathTools/lib/File/Spec/OS2.pm
@​@​ -4,7 +4,7 @​@​ use strict;
use vars qw(@​ISA $VERSION);
require File​::Spec​::Unix;

-$VERSION = '3.56';
+$VERSION = '3.57';
$VERSION =~ tr/_//;

@​ISA = qw(File​::Spec​::Unix);
diff --git a/dist/PathTools/lib/File/Spec/Unix.pm
b/dist/PathTools/lib/File/Spec/Unix.pm
index f76b29e..48e2b60 100644
--- a/dist/PathTools/lib/File/Spec/Unix.pm
+++ b/dist/PathTools/lib/File/Spec/Unix.pm
@​@​ -3,7 +3,7 @​@​ package File​::Spec​::Unix;
use strict;
use vars qw($VERSION);

-$VERSION = '3.56';
+$VERSION = '3.57';
my $xs_version = $VERSION;
$VERSION =~ tr/_//;

diff --git a/dist/PathTools/lib/File/Spec/VMS.pm
b/dist/PathTools/lib/File/Spec/VMS.pm
index 254f524..5e4a3b3 100644
--- a/dist/PathTools/lib/File/Spec/VMS.pm
+++ b/dist/PathTools/lib/File/Spec/VMS.pm
@​@​ -4,7 +4,7 @​@​ use strict;
use vars qw(@​ISA $VERSION);
require File​::Spec​::Unix;

-$VERSION = '3.56';
+$VERSION = '3.57';
$VERSION =~ tr/_//;

@​ISA = qw(File​::Spec​::Unix);
diff --git a/dist/PathTools/lib/File/Spec/Win32.pm
b/dist/PathTools/lib/File/Spec/Win32.pm
index 53f3854..77e0fed 100644
--- a/dist/PathTools/lib/File/Spec/Win32.pm
+++ b/dist/PathTools/lib/File/Spec/Win32.pm
@​@​ -5,7 +5,7 @​@​ use strict;
use vars qw(@​ISA $VERSION);
require File​::Spec​::Unix;

-$VERSION = '3.56';
+$VERSION = '3.57';
$VERSION =~ tr/_//;

@​ISA = qw(File​::Spec​::Unix);
--
1.7.9.msysgit.0

@p5pRT
Copy link
Author

p5pRT commented Jul 31, 2015

From @bulk88

On Thu Jul 30 16​:09​:24 2015, wuhaoecho@​gmail.com wrote​:

since you change

- $ENV{'PWD'} = EPOC​::getcwd();
- return $ENV{'PWD'};
+ return $ENV{'PWD'} = EPOC​::getcwd();

why not change all

+ $ENV{'PWD'} = $pwd;
+ return $pwd;

to

return $ENV{'PWD'} = $pwd;

?

sub _epoc_cwd {
  return $ENV{'PWD'} = EPOC​::getcwd();
}

to

sub _epoc_cwd {
  my $pwd = EPOC​::getcwd();
  $ENV{'PWD'} = $pwd;
  return $pwd;
}

makes no sense.

sub _epoc_cwd {
  my $pwd = EPOC​::getcwd();
  $ENV{'PWD'} = $pwd;
  return $pwd;
}

has 2 extra nextstate ops. one lvalue_intro op for the my line. 1 extra assignment op. 3 extra pad fetch ops. I didnt benchmark it, but I dont see that many extra ops being faster than scanning the linked list for magic. In the other subs, $pwd was read and written to in each line and there were multiple lines. In the epoc version there was no modifying, and only one line.

Read the commit message, I'll repost the relevant part.


Return the lexical instead of the magic var so there isn't a search for magic from pp_leavesub's sv_mortalcopy. Even though env mg vtable doesn't have a getter or GMAGIC, SvVSTRING_mg executes mg_find for random, get and set magic inside Perl_sv_setsv_flags.


--
bulk88 ~ bulk88 at hotmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant