From 50bdec410adaf4acacd40444203799ac110e34d8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 8 Jan 2007 15:17:18 +0000 Subject: [PATCH] * Huge speedup in patch propagation (20 minutes or so to 3 seconds). --- scripts/generate-patches.pl.in | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/scripts/generate-patches.pl.in b/scripts/generate-patches.pl.in index 4a0233f0f..8af5de9fe 100755 --- a/scripts/generate-patches.pl.in +++ b/scripts/generate-patches.pl.in @@ -348,11 +348,22 @@ foreach my $p (keys %dstOutPaths) { # patches that produce either paths in the destination or paths that # can be used as the base for other useful patches). +print "propagating patches...\n"; + my $changed; do { # !!! we repeat this to reach the transitive closure; inefficient $changed = 0; + print "loop\n"; + + my %dstBasePaths; + foreach my $q (keys %dstPatches) { + foreach my $patch (@{$dstPatches{$q}}) { + $dstBasePaths{$patch->{basePath}} = 1; + } + } + foreach my $p (keys %srcPatches) { my $patchList = $srcPatches{$p}; @@ -360,22 +371,18 @@ do { # Is path $p included in the destination? If so, include # patches that produce it. - $include = 1 if (defined $dstNarFiles{$p}); + $include = 1 if defined $dstNarFiles{$p}; # Is path $p a path that serves as a base for paths in the # destination? If so, include patches that produce it. - foreach my $q (keys %dstPatches) { - foreach my $patch (@{$dstPatches{$q}}) { - # !!! check baseHash - $include = 1 if ($p eq $patch->{basePath}); - } - } + # !!! check baseHash + $include = 1 if defined $dstBasePaths{$p}; if ($include) { foreach my $patch (@{$patchList}) { $changed = 1 if addPatch \%dstPatches, $p, $patch; } - } + } }