po: memoized istranslatable, eventually

And enjoy a 10% rebuild time enhancement on a complex wiki full of maps and
other pseudo-dynamic content, with some other costly plugins enabled. So it
could well mean 20% on a more usual wiki.

Signed-off-by: intrigeri <intrigeri@boum.org>
master
intrigeri 2008-11-12 22:32:47 +01:00
parent 10c4e858b8
commit 36312b13b4
1 changed files with 5 additions and 3 deletions

View File

@ -23,6 +23,7 @@ my %translations;
my @origneedsbuild; my @origneedsbuild;
my %origsubs; my %origsubs;
memoize("istranslatable");
memoize("_istranslation"); memoize("_istranslation");
memoize("percenttranslated"); memoize("percenttranslated");
@ -508,7 +509,8 @@ sub istranslatable ($) { #{{{
return 0 unless defined $file; return 0 unless defined $file;
return 0 if (defined pagetype($file) && pagetype($file) eq 'po'); return 0 if (defined pagetype($file) && pagetype($file) eq 'po');
return 0 if $file =~ /\.pot$/; return 0 if $file =~ /\.pot$/;
return pagespec_match($page, $config{po_translatable_pages}); return 1 if pagespec_match($page, $config{po_translatable_pages});
return;
} #}}} } #}}}
sub _istranslation ($) { #{{{ sub _istranslation ($) { #{{{
@ -537,8 +539,7 @@ sub istranslation ($) { #{{{
if (1 < (my ($masterpage, $lang) = _istranslation($page))) { if (1 < (my ($masterpage, $lang) = _istranslation($page))) {
my $hasleadingslash = ($masterpage=~s#^/##); my $hasleadingslash = ($masterpage=~s#^/##);
$translations{$masterpage}{$lang}=$page unless exists $translations{$masterpage}{$lang}; $translations{$masterpage}{$lang}=$page unless exists $translations{$masterpage}{$lang};
return (maybe_add_leading_slash($masterpage, $hasleadingslash), $lang) return (maybe_add_leading_slash($masterpage, $hasleadingslash), $lang);
if istranslatable($masterpage);
} }
return; return;
} #}}} } #}}}
@ -660,6 +661,7 @@ sub resettranslationscache() { #{{{
} #}}} } #}}}
sub flushmemoizecache() { #{{{ sub flushmemoizecache() { #{{{
Memoize::flush_cache("istranslatable");
Memoize::flush_cache("_istranslation"); Memoize::flush_cache("_istranslation");
Memoize::flush_cache("percenttranslated"); Memoize::flush_cache("percenttranslated");
} #}}} } #}}}