Subject: | use of memoize is broken; this patch makes things FAST |
Memoize without a normalizer will look for identical arguments through all of @_. The first arg
is the model object, in the uses in Perldoc::Server. The object is explicitly made anew per
request. Memoize gains nothing.
This patch makes memoize works, so many pages now load in .05s instead of 3.75s on my
laptop. Awesome!
Thanks for Perldoc::Server. It's been *very* helpful in proofing my Pod before uploading code.
--
rjbs
Subject: | perldoc-memoize.diff |
diff -Nur Perldoc-Server-0.07/lib/Perldoc/Server/Model/Pod.pm Perldoc-Server-0.07-rjbs/lib/Perldoc/Server/Model/Pod.pm
--- Perldoc-Server-0.07/lib/Perldoc/Server/Model/Pod.pm 2009-08-04 09:05:48.000000000 -0400
+++ Perldoc-Server-0.07-rjbs/lib/Perldoc/Server/Model/Pod.pm 2009-12-21 10:43:08.000000000 -0500
@@ -9,7 +9,7 @@
use Memoize;
use Pod::Simple::Search;
-memoize('section');
+memoize('section', NORMALIZER => sub { $_[1] });
sub ACCEPT_CONTEXT {
my ( $self, $c, @extra_arguments ) = @_;
@@ -68,6 +68,7 @@
return $section;
}
}
+ return;
}
=head1 NAME
diff -Nur Perldoc-Server-0.07/lib/Perldoc/Server/Model/Section.pm Perldoc-Server-0.07-rjbs/lib/Perldoc/Server/Model/Section.pm
--- Perldoc-Server-0.07/lib/Perldoc/Server/Model/Section.pm 2009-08-04 09:05:48.000000000 -0400
+++ Perldoc-Server-0.07-rjbs/lib/Perldoc/Server/Model/Section.pm 2009-12-21 10:46:08.000000000 -0500
@@ -6,7 +6,7 @@
use parent 'Catalyst::Model';
use Memoize;
-memoize('pages');
+memoize('pages', NORMALIZER => sub { $_[1] });
our @section_data = (
{