From: Ilya Zakharevich Date: Mon, 26 Jul 1999 01:09:00 +0000 (-0400) Subject: decrease memory footprint of standard modules X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e3d0cac0c3bf9ec77cb3e2fc362639f009d309e4;p=p5sagit%2Fp5-mst-13.2.git decrease memory footprint of standard modules Message-Id: <199907260509.BAA26303@monk.mps.ohio-state.edu> p4raw-id: //depot/perl@3794 --- diff --git a/configpm b/configpm index dd9e858..66b51a4 100755 --- a/configpm +++ b/configpm @@ -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 84298cb..d43b8ca 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 66c764f..8e15c1f 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 311d953..c4e9175 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