This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid %Config check on Errno load if it was built with PERL_BUILD_EXPAND_CONFIG_VARS
authorTodd Rinaldo <toddr@cpan.org>
Wed, 26 Aug 2015 21:49:58 +0000 (16:49 -0500)
committerTony Cook <tony@develop-help.com>
Thu, 27 Aug 2015 01:54:53 +0000 (11:54 +1000)
Any person who built perl with this environment variable already has locked their
install to the given platform. Therefore this check should be unnecessary on
those installs. This reduces runtime bloat because Config does not have to be
loaded any time someone uses $! or Errno directly.

ext/Errno/Errno_pm.PL

index c6bfa06..1d9c048 100644 (file)
@@ -2,7 +2,7 @@ use ExtUtils::MakeMaker;
 use Config;
 use strict;
 
-our $VERSION = "1.23";
+our $VERSION = "1.24";
 
 my %err = ();
 
@@ -278,13 +278,24 @@ sub write_errno_pm {
 
 package Errno;
 require Exporter;
-use Config;
 use strict;
 
+EDQ
+
+    # Errno only needs Config to make sure it hasn't changed platforms.
+    # If someone set $ENV{PERL_BUILD_EXPAND_CONFIG_VARS} at build time,
+    # they've already declared perl doesn't need to worry about this risk.
+    if(!$ENV{'PERL_BUILD_EXPAND_CONFIG_VARS'}) {
+        print <<"CONFIG_CHECK_END";
+use Config;
 "\$Config{'archname'}-\$Config{'osvers'}" eq
 "$archname-$Config{'osvers'}" or
        die "Errno architecture ($archname-$Config{'osvers'}) does not match executable architecture (\$Config{'archname'}-\$Config{'osvers'})";
 
+CONFIG_CHECK_END
+}
+
+    print <<"EDQ";
 our \$VERSION = "$VERSION";
 \$VERSION = eval \$VERSION;
 our \@ISA = 'Exporter';