Revision: 1306 Author: [email protected] Date: Wed Jun 16 16:07:50 2010 Log: Add cache to make_path_strip_editor()
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1306 Modified: /trunk/lib/Devel/NYTProf/Util.pm ======================================= --- /trunk/lib/Devel/NYTProf/Util.pm Mon Jun 7 07:10:32 2010 +++ /trunk/lib/Devel/NYTProf/Util.pm Wed Jun 16 16:07:50 2010 @@ -96,12 +96,18 @@ my @inc = @$inc_ref or return; - my $inc_regex = get_abs_paths_alternation_regex(\...@inc); - - # anchor at start, capture anchor - $inc_regex = qr{($anchor)$inc_regex}; - - return sub { $_[0] =~ s{$inc_regex}{$1$replacement} }; + our %make_path_strip_editor_cache; + my $key = join "\t", $anchor, $replacement, @inc; + + return $make_path_strip_editor_cache{$key} ||= do { + + my $inc_regex = get_abs_paths_alternation_regex(\...@inc); + + # anchor at start, capture anchor + $inc_regex = qr{($anchor)$inc_regex}; + + sub { $_[0] =~ s{$inc_regex}{$1$replacement} }; + }; } -- You've received this message because you are subscribed to the Devel::NYTProf Development User group. Group hosted at: http://groups.google.com/group/develnytprof-dev Project hosted at: http://perl-devel-nytprof.googlecode.com CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf To post, email: [email protected] To unsubscribe, email: [email protected]
