From 06b955b84a0abec6d6baae9eb295793574cb76d7 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 10 Apr 2007 01:18:03 +0000 Subject: [PATCH] * Add a new %destsources hash, which maps between a destination file and the source page used to create it, ie it's the reverse of %renderedfiles. * Use %destsources in htmllink and urlto for 20-50% speedup. --- IkiWiki.pm | 34 ++++++++++++++++++++-------------- debian/changelog | 5 ++++- doc/plugins/write.mdwn | 6 +++--- doc/roadmap.mdwn | 2 +- po/ikiwiki.pot | 4 ++-- 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index b56c62801..a6bfddab0 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -9,8 +9,8 @@ use URI::Escape q{uri_escape_utf8}; use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase - %renderedfiles %oldrenderedfiles %pagesources %depends %hooks - %forcerebuild $gettext_obj}; + %renderedfiles %oldrenderedfiles %pagesources %destsources + %depends %hooks %forcerebuild $gettext_obj}; use Exporter q{import}; our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match @@ -328,9 +328,13 @@ sub will_render ($$;$) { #{{{ $renderedfiles{$page}=[$dest, grep { $_ ne $dest } @{$renderedfiles{$page}}]; } else { + foreach my $old (@{$renderedfiles{$page}}) { + delete $destsources{$old}; + } $renderedfiles{$page}=[$dest]; $cleared{$page}=1; } + $destsources{$dest}=$page; } #}}} sub bestlink ($$) { #{{{ @@ -455,7 +459,7 @@ sub urlto ($$) { #{{{ return beautify_url(baseurl($from)); } - if (! grep { $_ eq $to } map { @{$_} } values %renderedfiles) { + if (! $destsources{$to}) { $to=htmlpage($to); } @@ -489,18 +493,19 @@ sub htmllink ($$$;@) { #{{{ return "$linktext" if length $bestlink && $page eq $bestlink; - if (! grep { $_ eq $bestlink } map { @{$_} } values %renderedfiles) { + if (! $destsources{$bestlink}) { $bestlink=htmlpage($bestlink); - } - if (! grep { $_ eq $bestlink } map { @{$_} } values %renderedfiles) { - return $linktext unless length $config{cgiurl}; - return " "create", - page => pagetitle(lc($link), 1), - from => $lpage - ). - "\">?$linktext" + + if (! $destsources{$bestlink}) { + return $linktext unless length $config{cgiurl}; + return " "create", + page => pagetitle(lc($link), 1), + from => $lpage + ). + "\">?$linktext" + } } $bestlink=abs2rel($bestlink, dirname(htmlpage($page))); @@ -723,6 +728,7 @@ sub loadindex () { #{{{ $oldlinks{$page}=[@{$items{link}}]; $links{$page}=[@{$items{link}}]; $depends{$page}=$items{depends}[0] if exists $items{depends}; + $destsources{$_}=$page foreach @{$items{dest}}; $renderedfiles{$page}=[@{$items{dest}}]; $oldrenderedfiles{$page}=[@{$items{dest}}]; $pagecase{lc $page}=$page; diff --git a/debian/changelog b/debian/changelog index 1910dfc4e..570c15d28 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,8 +10,11 @@ ikiwiki (1.50) UNRELEASED; urgency=low [ Joey Hess ] * Add support for PROFILE=1 to the Makefile, this turns on profiling of the wiki build using Devel::Profiler (Dprof can't handle ikiwiki). + * Add a new %destsources hash, which maps between a destination file and + the source page used to create it, ie it's the reverse of %renderedfiles. + * Use %destsources in htmllink and urlto for 20-50% speedup. - -- Joey Hess Mon, 09 Apr 2007 20:22:44 -0400 + -- Joey Hess Mon, 09 Apr 2007 21:09:32 -0400 ikiwiki (1.49) unstable; urgency=low diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index c42660194..4dd057074 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -266,9 +266,9 @@ use the following hashes, using a page name as the key: * `links` lists the names of each page that a page links to, in an array reference. -* `%renderedfiles` lists names of the files rendered by a page, in an array - reference. -* `%pagesources` contains the name of the source file for a page. +* `%destsources` contains the name of the source file used to create each + destination file. +* `%pagesources` contains the name of the source file for each page. Also, the %IkiWiki::version variable contains the version number for the ikiwiki program. diff --git a/doc/roadmap.mdwn b/doc/roadmap.mdwn index 918a4806d..f118be10b 100644 --- a/doc/roadmap.mdwn +++ b/doc/roadmap.mdwn @@ -20,7 +20,7 @@ Released 29 April 2006. * Should have fully working [[todo/utf8]] support. (./) * [[Optimised_rendering|todo/optimisations]] if possible. Deal with other scalability issues. _(status: scales to thousands of pages, and approximatly - 3x as fast as version 1.0)_ (./) + 3.5 times as fast as version 1.0)_ (./) * Improved [[todo/html]] stylesheets and templates. * Improved scalable [[logo]]. (./) * Support for at other revision control systems aside from svn. diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index f7d93e834..3bb115ee9 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2007-04-09 20:10-0400\n" +"POT-Creation-Date: 2007-04-09 21:13-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -553,7 +553,7 @@ msgstr "" #. translators: preprocessor directive name, #. translators: the second a page name, the #. translators: third a number. -#: ../IkiWiki.pm:620 +#: ../IkiWiki.pm:625 #, perl-format msgid "%s preprocessing loop detected on %s at depth %i" msgstr "" -- 2.44.0