]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Work around very innefficient behavior in File::Spec::abs2rel. Result
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Tue, 4 Jul 2006 03:42:19 +0000 (03:42 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Tue, 4 Jul 2006 03:42:19 +0000 (03:42 +0000)
    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
IkiWiki/Render.pm
debian/changelog

index d7c082b1decf3e691048bc8eaea1e863404f58d4..56a27b3b02a4f32db7d678c0edec07d9df9ab242 100644 (file)
@@ -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\" />";
index 40472693084d905b00373f504a57a1069aff871b..d88ec93d36f8f46ac6578d74917cfc3b1af9905f 100644 (file)
@@ -4,7 +4,6 @@ package IkiWiki;
 
 use warnings;
 use strict;
-use File::Spec;
 use IkiWiki;
 use Encode;
 
@@ -48,7 +47,7 @@ sub backlinks ($) { #{{{
        foreach my $p (keys %links) {
                next if bestlink($page, $p) eq $page;
                if (grep { length $_ && bestlink($p, $_) eq $page } @{$links{$p}}) {
-                       my $href=File::Spec->abs2rel(htmlpage($p), dirname($page));
+                       my $href=abs2rel(htmlpage($p), dirname($page));
                        
                        # Trim common dir prefixes from both pages.
                        my $p_trimmed=$p;
index 7fc285bcbfaf6b87913987f94dc1480f2496383f..08e2142d16f3ae9b2e6d1d39b271ce71442bb81c 100644 (file)
@@ -32,14 +32,18 @@ ikiwiki (1.8) UNRELEASED; urgency=low
   * Add a html plugin, which can be used to write wikis in raw html,
     if you'd ever want to do such a thing. Slightly tricky, since ikiwiki
     defaults to not processing .html files, since w/o this plugin they would
-    be copied unsanitised. With this plugin, it will process, and html
+    be copied unsanitised. With this plugin, it will process and html
     sanitise them, like any other page type.
   * Rebuilding wrappers is necessary on upgrade to this version.
   * Make ikiwiki --setup --refresh rebuild wrappers, so wrapper rebuild
     will be automatically done on all upgrades.
-  * Don't sent pings if the wiki is being rebuilt.
+  * Don't send pings if the wiki is being rebuilt.
+  * 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!
 
- -- Joey Hess <joeyh@debian.org>  Mon,  3 Jul 2006 21:01:28 -0400
+ -- Joey Hess <joeyh@debian.org>  Mon,  3 Jul 2006 23:33:57 -0400
 
 ikiwiki (1.7) unstable; urgency=low