summaryrefslogtreecommitdiff
path: root/configpm
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-06-20 11:37:40 +0100
committerNicholas Clark <nick@ccl4.org>2010-06-23 08:44:42 +0100
commita5094cb03518019abe3dfffccbe657c8edc0e0c2 (patch)
tree8d82fd6e699c483096fddb4c823bee069dbe3b0c /configpm
parentf897bda4768f481fed99f4d632f63dbecb999c01 (diff)
downloadperl-a5094cb03518019abe3dfffccbe657c8edc0e0c2.tar.gz
In Config::import, avoid assigning to $pkg, which is never read.
Avoid the use of sprintf - __PACKAGE__ is a constant, so can be inlined within the message string. Don't store '%Config' in %Export_Cache, as that's only used to deal with exported functions. The variable %Config is special-cased. On this platform, cachegrind shows a 1% reduction in instruction count and L1 cache references as a result.
Diffstat (limited to 'configpm')
-rwxr-xr-xconfigpm11
1 files changed, 7 insertions, 4 deletions
diff --git a/configpm b/configpm
index 4deb4d91f8..87feab57fb 100755
--- a/configpm
+++ b/configpm
@@ -188,13 +188,16 @@ sub config_sh;
sub config_vars;
sub config_re;
-my %%Export_Cache = map {($_ => 1)} (@Config::EXPORT, @Config::EXPORT_OK);
+# 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;
our %%Config;
# Define our own import method to avoid pulling in the full Exporter:
sub import {
- my $pkg = shift;
+ shift;
@_ = @Config::EXPORT unless @_;
my @funcs = grep $_ ne '%%Config', @_;
@@ -203,8 +206,8 @@ sub import {
no strict 'refs';
my $callpkg = caller(0);
foreach my $func (@funcs) {
- die sprintf qq{"%%s" is not exported by the %%s module\n},
- $func, __PACKAGE__ unless $Export_Cache{$func};
+ die qq{"$func" is not exported by the Config module\n}
+ unless $Export_Cache{$func};
*{$callpkg.'::'.$func} = \&{$func};
}