summaryrefslogtreecommitdiff
path: root/configpm
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-02-16 17:15:46 +0000
committerNicholas Clark <nick@ccl4.org>2011-02-17 16:28:36 +0000
commitc6b7b56c8549a3570120ea861853b7f5cbb02733 (patch)
treeac915a82f7435cbe49577475bdd71424e7e272f7 /configpm
parent2dc5eb262048fb23343826c58c3b2c0af832252a (diff)
downloadperl-c6b7b56c8549a3570120ea861853b7f5cbb02733.tar.gz
Refactor Config.pm to set @EXPORT_OK from keys %Export_Cache
The refactor generates %Export_Cache at perl build time, and hence avoids Config.pm running a map on load. The change also results in @Config::EXPORT containing shared hash key scalars, which saves 124 bytes on this platform, modest, but everything helps. Also change the build script to programmatically generate the function stubs in Config.pm, instead of having the list duplicated by hand.
Diffstat (limited to 'configpm')
-rwxr-xr-xconfigpm29
1 files changed, 18 insertions, 11 deletions
diff --git a/configpm b/configpm
index cad3a9ab88..f08a194da9 100755
--- a/configpm
+++ b/configpm
@@ -168,9 +168,14 @@ sub _V {
ENDOFBEG
-my $myver = sprintf "%vd", $^V;
+my $export_funcs = <<'EOT';
+my %Export_Cache = (myconfig => 1,
+ config_sh => 1, config_vars => 1, config_re => 1);
+EOT
-$config_txt .= sprintf <<'ENDOFBEG', ($myver) x 3;
+my %export_ok = eval $export_funcs or die;
+
+$config_txt .= sprintf << 'EOT', $export_funcs;
# This file was created by configpm when Perl was built. Any changes
# made to this file will be lost the next time perl is built.
@@ -182,22 +187,24 @@ package Config;
use strict;
# use warnings; Pulls in Carp
# use vars pulls in Carp
+
+# Skip @Config::EXPORT because it only contains %%Config, which we special
+# case below as it's not a function. @Config::EXPORT won't change in the
+# lifetime of Perl 5.
+%s
@Config::EXPORT = qw(%%Config);
-@Config::EXPORT_OK = qw(myconfig config_sh config_vars config_re);
+@Config::EXPORT_OK = keys %%Export_Cache;
# Need to stub all the functions to make code such as print Config::config_sh
# keep working
-sub myconfig;
-sub config_sh;
-sub config_vars;
-sub config_re;
+EOT
-# Skip @Config::EXPORT because it only contains %%Config, which we special
-# case below as it's not a function. @Config::EXPORT won't change in the
-# lifetime of Perl 5.
-my %%Export_Cache = map {($_ => 1)} @Config::EXPORT_OK;
+$config_txt .= "sub $_;\n" foreach sort keys %export_ok;
+my $myver = sprintf "%vd", $^V;
+
+$config_txt .= sprintf <<'ENDOFBEG', ($myver) x 3;
our %%Config;
# Define our own import method to avoid pulling in the full Exporter: