aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>2009-08-24 23:01:42 +0100
committerSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>2009-08-25 00:31:16 +0100
commit7227c2debfeef94b35f7d81f42900aa01820caa3 (patch)
tree8afce2b036659b0f03aa8822215658d7b7d0bf94 /IkiWiki.pm
parent2cf26fd709efa802b93109935b4203590d549810 (diff)
downloadikiwiki-7227c2debfeef94b35f7d81f42900aa01820caa3.tar
ikiwiki-7227c2debfeef94b35f7d81f42900aa01820caa3.tar.gz
Use a hash to de-duplicate dependencies
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm19
1 files changed, 6 insertions, 13 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 734b167cf..21a74adce 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -1508,10 +1508,12 @@ sub loadindex () {
$oldlinks{$page}=[@{$d->{links}}];
}
if (exists $d->{dependslist}) {
- $depends{$page}=$d->{dependslist};
+ $depends{$page}={
+ map { $_ => 1 } @{$d->{dependslist}}
+ };
}
elsif (exists $d->{depends}) {
- $depends{$page}=[$d->{depends}];
+ $depends{$page}={$d->{depends} => 1};
}
if (exists $d->{state}) {
$pagestate{$page}=$d->{state};
@@ -1557,7 +1559,7 @@ sub saveindex () {
};
if (exists $depends{$page}) {
- $index{page}{$src}{dependslist} = $depends{$page};
+ $index{page}{$src}{dependslist} = [ keys %{$depends{$page}} ];
}
if (exists $pagestate{$page}) {
@@ -1730,16 +1732,7 @@ sub add_depends ($$) {
return unless pagespec_valid($pagespec);
- if (! exists $depends{$page}) {
- $depends{$page}=[$pagespec];
- }
- else {
- foreach my $p (@{$depends{$page}}) {
- return 1 if $p eq $pagespec;
- }
- push @{$depends{$page}}, $pagespec;
- }
-
+ $depends{$page}{$pagespec} = 1;
return 1;
}