diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-09-02 11:44:51 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-09-02 11:44:51 +0100 |
commit | f4b4ed7b4eca79b25054dfeafa0aac0dbd41a507 (patch) | |
tree | d8761e2885f7698b08700ab5c310f7b788baa061 /dist/XSLoader | |
parent | f3a0defb95e2da85126a0bd17bf5d67899fff9b3 (diff) | |
download | perl-f4b4ed7b4eca79b25054dfeafa0aac0dbd41a507.tar.gz |
For the generated XSLoader.pm, avoid a runtime lexical which is constant.
XSLoader_pm.PL had been resolving $Config::Config{dlext}, and writing it as
the constant initialiser for a lexical variable in XSLoader.pm. In turn,
that lexical was used only once, in string interpolation. So the interpolation
can be done instead at build time.
Diffstat (limited to 'dist/XSLoader')
-rw-r--r-- | dist/XSLoader/XSLoader_pm.PL | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/dist/XSLoader/XSLoader_pm.PL b/dist/XSLoader/XSLoader_pm.PL index a258f6ea51..f2e5bbc922 100644 --- a/dist/XSLoader/XSLoader_pm.PL +++ b/dist/XSLoader/XSLoader_pm.PL @@ -1,13 +1,6 @@ use strict; use Config; -sub to_string { - my ($value) = @_; - $value =~ s/\\/\\\\/g; - $value =~ s/'/\\'/g; - return "'$value'"; -} - 1 while unlink "XSLoader.pm"; open OUT, ">XSLoader.pm" or die $!; print OUT <<'EOT'; @@ -15,19 +8,13 @@ print OUT <<'EOT'; package XSLoader; -$VERSION = "0.10"; +$VERSION = "0.11"; #use strict; # enable debug/trace messages from DynaLoader perl code # $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug; -EOT - -print OUT ' my $dl_dlext = ', to_string($Config::Config{'dlext'}), ";\n" ; - -print OUT <<'EOT'; - package DynaLoader; # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here. @@ -74,7 +61,15 @@ print OUT <<'EOT'; my $modlibname = (caller())[1]; my $c = @modparts; $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename - my $file = "$modlibname/auto/$modpname/$modfname.$dl_dlext"; +EOT + +my $dl_dlext = quotemeta($Config::Config{'dlext'}); + +print OUT <<"EOT"; + my \$file = "\$modlibname/auto/\$modpname/\$modfname.$dl_dlext"; +EOT + +print OUT <<'EOT'; # print STDERR "XSLoader::load for $module ($file)\n" if $dl_debug; |