don't use pagespec_match_list
authorJoey Hess <joey@gnu.kitenet.net>
Tue, 25 Aug 2009 21:46:15 +0000 (17:46 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Tue, 25 Aug 2009 21:54:36 +0000 (17:54 -0400)
This should be more efficient than pagespec_match_list since it short-circuits
after the first match is found.

The other problem with using pagespec_match_list here is it may throw an
error if a bad or failing pagespec somehow got into the dependencies.

IkiWiki/Render.pm

index fb28b6e3bb43b48f182496944fcd61df8029d5b4..da2d7b4ccc1adc480c2acc20f6b5d167a8fc7ff2 100644 (file)
@@ -460,19 +460,21 @@ sub refresh () {
                        my $p=pagename($f);
                        if (exists $depends{$p}) {
                                foreach my $d (keys %{$depends{$p}}) {
+                                       my $sub=pagespec_translate($d);
+                                       next if $@ || ! defined $sub;
+
                                        # only consider internal files
-                                       # if the page explicitly depends on such files
-                                       my @pages = map {
-                                               pagename($_)
-                                       } grep {
-                                               $_ ne $f
-                                       } (@changed, $d =~ /internal\(/ ? @internal : ());
-                                       @pages = pagespec_match_list(\@pages, $d, location => $p);
-                                       if (@pages) {
-                                               debug(sprintf(gettext("building %s, which depends on %s"), $f, $pages[0]));
-                                               render($f);
-                                               $rendered{$f}=1;
-                                               next F;
+                                       # if the page explicitly depends
+                                       # on such files
+                                       foreach my $file (@changed, $d =~ /internal\(/ ? @internal : ()) {
+                                               next if $file eq $f;
+                                               my $page=pagename($file);
+                                               if ($sub->($page, location => $p)) {
+                                                       debug(sprintf(gettext("building %s, which depends on %s"), $f, $page));
+                                                       render($f);
+                                                       $rendered{$f}=1;
+                                                       next F;
+                                               }
                                        }
                                }
                        }