X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMemoize.pm;h=cf8454227ca3666dfa2a54c9f0700515db4d9140;hb=c1e8580e8ecd78fc1f67b0caa695b9884a700d93;hp=6907400e029df5590e9cafbc159195a3d17e6c41;hpb=3d4a255cbdf51bdaf16ab1a302f453e90e07602f;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Memoize.pm b/lib/Memoize.pm index 6907400..cf84542 100644 --- a/lib/Memoize.pm +++ b/lib/Memoize.pm @@ -8,10 +8,10 @@ # same terms as Perl itself. If in doubt, # write to mjd-perl-memoize+@plover.com for a license. # -# Version 0.66 $Revision: 1.18 $ $Date: 2001/06/24 17:16:47 $ +# Version 1.01 $Revision: 1.18 $ $Date: 2001/06/24 17:16:47 $ package Memoize; -$VERSION = '0.66'; +$VERSION = '1.01_01'; # Compile-time constants sub SCALAR () { 0 } @@ -176,8 +176,8 @@ sub _my_tie { my $shortopt = (ref $fullopt) ? $fullopt->[0] : $fullopt; return unless defined $shortopt && $shortopt eq 'TIE'; - carp("TIE option to memoize() is deprecated; use HASH instead") if $^W; - + carp("TIE option to memoize() is deprecated; use HASH instead") + if $^W; my @args = ref $fullopt ? @$fullopt : (); shift @args; @@ -357,10 +357,11 @@ sub _crap_out { =head1 NAME -Memoize - Make your functions faster by trading space for time +Memoize - Make functions faster by trading space for time =head1 SYNOPSIS + # This is the documentation for Memoize 1.01 use Memoize; memoize('slow_function'); slow_function(arguments); # Is faster than it was before @@ -462,7 +463,7 @@ this: Since there are relatively few objects in a picture, there are only a few colors, which get looked up over and over again. Memoizing -C speeded up the program by several percent. +C sped up the program by several percent. =head1 DETAILS @@ -692,15 +693,18 @@ because all its results have been precomputed. =item C -This option is B and will be removed -in the B release of C. Use the C option instead. +This option is no longer supported. It is still documented only to +aid in the debugging of old programs that use it. Old programs should +be converted to use the C option instead. memoize ... [TIE, PACKAGE, ARGS...] is merely a shortcut for require PACKAGE; - tie my %cache, PACKAGE, ARGS...; + { my %cache; + tie %cache, PACKAGE, ARGS...; + } memoize ... [HASH => \%cache]; =item C @@ -975,15 +979,12 @@ in Perl, and until it is resolved, memoized functions will see a slightly different C and will perform a little more slowly on threaded perls than unthreaded perls. -Here's a bug that isn't my fault: Some versions of C won't -let you store data under a key of length 0. That means that if you -have a function C which you memoized and the cache is in a -C database, then the value of C (C called with no -arguments) will not be memoized. Let us all breathe deeply and repeat -this mantra: ``Gosh, Keith, that sure was a stupid thing to do.'' If -this is a big problem, you can write a tied hash class which is a -front-end to C that prepends to every key before storing -it. +Some versions of C won't let you store data under a key of +length 0. That means that if you have a function C which you +memoized and the cache is in a C database, then the value of +C (C called with no arguments) will not be memoized. If this +is a big problem, you can supply a normalizer function that prepends +C<"x"> to every key. =head1 MAILING LIST