diff options
author | Ilya Zakharevich <ilya@math.berkeley.edu> | 1999-07-25 21:09:00 -0400 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-07-27 08:59:58 +0000 |
commit | e3d0cac0c3bf9ec77cb3e2fc362639f009d309e4 (patch) | |
tree | 337c2dbaadc3b48e57e882b4b678eecc53c92aec | |
parent | 538feb029e0f72a0968673b94ed4dca853d5473f (diff) | |
download | perl-e3d0cac0c3bf9ec77cb3e2fc362639f009d309e4.tar.gz |
decrease memory footprint of standard modules
Message-Id: <199907260509.BAA26303@monk.mps.ohio-state.edu>
p4raw-id: //depot/perl@3794
-rwxr-xr-x | configpm | 19 | ||||
-rw-r--r-- | ext/POSIX/POSIX.pm | 10 | ||||
-rw-r--r-- | lib/AutoLoader.pm | 13 | ||||
-rw-r--r-- | lib/SelfLoader.pm | 7 |
4 files changed, 35 insertions, 14 deletions
@@ -19,13 +19,24 @@ my $glossary = $ARGV[1] || 'Porting/Glossary'; open CONFIG, ">$config_pm" or die "Can't open $config_pm: $!\n"; $myver = $]; -print CONFIG <<"ENDOFBEG"; +print CONFIG <<'ENDOFBEG_NOQ', <<"ENDOFBEG"; package Config; use Exporter (); -\@ISA = (Exporter); -\@EXPORT = qw(%Config); -\@EXPORT_OK = qw(myconfig config_sh config_vars); +@EXPORT = qw(%Config); +@EXPORT_OK = qw(myconfig config_sh config_vars); + +# Define our own import method to avoid pulling in the full Exporter: +sub import { + my $pkg = shift; + @_ = @EXPORT unless @_; + my @func = grep {$_ ne '%Config'} @_; + Exporter::import('Config', @func) if @func; + return if @func == @_; + my $callpkg = caller(0); + *{"$callpkg\::Config"} = \%Config; +} +ENDOFBEG_NOQ \$] == $myver or die "Perl lib version ($myver) doesn't match executable version (\$])"; diff --git a/ext/POSIX/POSIX.pm b/ext/POSIX/POSIX.pm index 84298cb69a..d43b8ca282 100644 --- a/ext/POSIX/POSIX.pm +++ b/ext/POSIX/POSIX.pm @@ -1,6 +1,7 @@ package POSIX; -use vars qw($VERSION @ISA %EXPORT_TAGS @EXPORT_OK $AUTOLOAD); +# use vars qw($VERSION @ISA %EXPORT_TAGS @EXPORT_OK $AUTOLOAD); +(@ISA, %EXPORT_TAGS,@EXPORT_OK,$AUTOLOAD) = (); use Carp; use AutoLoader; @@ -11,7 +12,7 @@ require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); -$VERSION = "1.02" ; +$VERSION = $VERSION = "1.03" ; %EXPORT_TAGS = ( @@ -161,7 +162,10 @@ $VERSION = "1.02" ; ); -Exporter::export_tags(); +# Exporter::export_tags(); +for (values %EXPORT_TAGS) { + push @EXPORT, @$_; +} @EXPORT_OK = qw( closedir opendir readdir rewinddir diff --git a/lib/AutoLoader.pm b/lib/AutoLoader.pm index 66c764f9d8..8e15c1f60c 100644 --- a/lib/AutoLoader.pm +++ b/lib/AutoLoader.pm @@ -1,17 +1,17 @@ package AutoLoader; -use vars qw(@EXPORT @EXPORT_OK $VERSION); +# use vars qw(@EXPORT @EXPORT_OK $VERSION); my $is_dosish; my $is_vms; BEGIN { require Exporter; - @EXPORT = (); - @EXPORT_OK = qw(AUTOLOAD); + @EXPORT = @EXPORT = (); + @EXPORT_OK = @EXPORT_OK = qw(AUTOLOAD); $is_dosish = $^O eq 'dos' || $^O eq 'os2' || $^O eq 'MSWin32'; $is_vms = $^O eq 'VMS'; - $VERSION = '5.56'; + $VERSION = $VERSION = '5.57'; } AUTOLOAD { @@ -103,7 +103,10 @@ sub import { # Export symbols, but not by accident of inheritance. # - Exporter::export $pkg, $callpkg, @_ if $pkg eq 'AutoLoader'; + if ($pkg eq 'AutoLoader') { + local $Exporter::ExportLevel = 1; + Exporter::import $pkg, @_; + } # # Try to find the autosplit index file. Eg., if the call package diff --git a/lib/SelfLoader.pm b/lib/SelfLoader.pm index 311d953721..c4e9175a79 100644 --- a/lib/SelfLoader.pm +++ b/lib/SelfLoader.pm @@ -1,5 +1,5 @@ package SelfLoader; -use Carp; +# use Carp; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(AUTOLOAD); @@ -9,6 +9,8 @@ $DEBUG = 0; my %Cache; # private cache for all SelfLoader's client packages +sub croak { require Carp; goto &Carp::croak } + AUTOLOAD { print STDERR "SelfLoader::AUTOLOAD for $AUTOLOAD\n" if $DEBUG; my $SL_code = $Cache{$AUTOLOAD}; @@ -92,7 +94,8 @@ sub _load_stubs { sub _add_to_cache { my($self,$fullname,$pack,$lines, $protoype) = @_; return () unless $fullname; - carp("Redefining sub $fullname") if exists $Cache{$fullname}; + (require Carp), Carp::carp("Redefining sub $fullname") + if exists $Cache{$fullname}; $Cache{$fullname} = join('', "package $pack; ",@$lines); print STDERR "SelfLoader cached $fullname: $Cache{$fullname}" if $DEBUG; # return stub to be eval'd |