summaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-07-04 03:42:19 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-07-04 03:42:19 +0000
commitebc6120f99ac5665efa4cfb84b5c6c898238c477 (patch)
treeae528c37c3e255c26eb3f82cccf2052d2a2cda36 /IkiWiki.pm
parentf877845353e5f8cfe6d3bdad625b9c2bacee878e (diff)
* 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!
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm16
1 files changed, 14 insertions, 2 deletions
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 ($$$;$$$) { #{{{
"\">?</a>$linktext</span>"
}
- require File::Spec;
- $bestlink=File::Spec->abs2rel($bestlink, dirname($page));
+ $bestlink=abs2rel($bestlink, dirname($page));
if (! $noimageinline && isinlinableimage($bestlink)) {
return "<img src=\"$bestlink\" alt=\"$linktext\" />";