In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/2d7e78b1bd24d3af5881f95a996405c9c11b1d59?hp=79a921544258c0f3466f44738c4f0d24399782dd>
- Log ----------------------------------------------------------------- commit 2d7e78b1bd24d3af5881f95a996405c9c11b1d59 Author: Nicholas Clark <[email protected]> Date: Thu Jun 17 15:21:24 2010 +0100 Avoid creating @EXPORT_FAIL in every package using Exporter. Previously, if package INKLE_KLINK is an Exporter, then the Exporter code's symbolic lookup of \...@{"INKLE_KLINK::EXPORT_FAIL"} would cause both that array and the enclosing typeglob to be instantiated. Now the typeglob and array are only created if present. (Strictly, if there's something in INKLE_KLINK's symbol table for EXPORT_FAIL. But likely that will only ever be the array.) This saves about 200 bytes per package that uses Exporter but does not need an @EXPORT_FAIL. ----------------------------------------------------------------------- Summary of changes: lib/Exporter.pm | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Exporter.pm b/lib/Exporter.pm index cd51828..c37f39c 100644 --- a/lib/Exporter.pm +++ b/lib/Exporter.pm @@ -9,7 +9,7 @@ require 5.006; our $Debug = 0; our $ExportLevel = 0; our $Verbose ||= 0; -our $VERSION = '5.64_01'; +our $VERSION = '5.64_02'; our (%Cache); sub as_heavy { @@ -35,9 +35,12 @@ sub import { } # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-( - my($exports, $fail) = (\...@{"$pkg\::EXPORT"}, \...@{"$pkg\::EXPORT_FAIL"}); + my $exports = \...@{"$pkg\::EXPORT"}; + # But, avoid creating things if they don't exist, which saves a couple of + # hundred bytes per package processed. + my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \...@{"$pkg\::EXPORT_FAIL"}; return export $pkg, $callpkg, @_ - if $Verbose or $Debug or @$fail > 1; + if $Verbose or $Debug or $fail && @$fail > 1; my $export_cache = ($Cache{$pkg} ||= {}); my $args = @_ or @_ = @$exports; @@ -51,7 +54,7 @@ sub import { # We bomb out of the loop with last as soon as heavy is set. if ($args or $fail) { ($heavy = (/\W/ or $args and not exists $export_cache->{$_} - or @$fail and $_ eq $fail->[0])) and last + or $fail and @$fail and $_ eq $fail->[0])) and last foreach (@_); } else { ($heavy = /\W/) and last -- Perl5 Master Repository
