From ebc6120f99ac5665efa4cfb84b5c6c898238c477 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 4 Jul 2006 03:42:19 +0000 Subject: * Work around very innefficient behavior in File::Spec::abs2rel. Result is a savings of 2 pointless fork/execs per link calculation, which results in ~25% speedup of ikiwiki building its own doc wiki, and about 35% speedup displaying RecentChanges! --- IkiWiki.pm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index d7c082b1d..56a27b3b0 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -260,6 +260,19 @@ sub styleurl (;$) { #{{{ return $page."style.css"; } #}}} +sub abs2rel ($$) { + # Work around very innefficient behavior in File::Spec if abs2rel + # is passed two relative paths. It's much faster if paths are + # absolute! + my $path="/".shift; + my $base="/".shift; + + require File::Spec; + my $ret=File::Spec->abs2rel($path, $base); + $ret=~s/^// if defined $ret; + return $ret; +} + sub htmllink ($$$;$$$) { #{{{ my $lpage=shift; # the page doing the linking my $page=shift; # the page that will contain the link (different for inline) @@ -292,8 +305,7 @@ sub htmllink ($$$;$$$) { #{{{ "\">?$linktext" } - require File::Spec; - $bestlink=File::Spec->abs2rel($bestlink, dirname($page)); + $bestlink=abs2rel($bestlink, dirname($page)); if (! $noimageinline && isinlinableimage($bestlink)) { return "\"$linktext\""; -- cgit v1.2.3