]> git.donarmstrong.com Git - debhelper.git/commitdiff
Memoize architecture comparisons in samearch, and avoid calling dpkg-architecture...
authorJoey Hess <joey@kitenet.net>
Mon, 26 Apr 2010 23:45:04 +0000 (19:45 -0400)
committerJoey Hess <joey@kitenet.net>
Mon, 26 Apr 2010 23:45:04 +0000 (19:45 -0400)
Debian/Debhelper/Dh_Lib.pm
debian/changelog

index d9c1d38955a3e6720bf348804ec1ab4a0097fdb2..421dd99647fa69f5f530493da00857d00925df02 100644 (file)
@@ -638,15 +638,34 @@ sub dpkg_architecture_value {
 }
 
 # Passed an arch and a list of arches to match against, returns true if matched
-sub samearch {
-       my $arch=shift;
-       my @archlist=split(/\s+/,shift);
+{
+       my %knownsame;
 
-       foreach my $a (@archlist) {
-               system("dpkg-architecture", "-a$arch", "-i$a") == 0 && return 1;
+       sub samearch {
+               my $arch=shift;
+               my @archlist=split(/\s+/,shift);
+       
+               foreach my $a (@archlist) {
+                       # Avoid expensive dpkg-architecture call to compare
+                       # with a simple architecture name. "linux-any" and
+                       # other architecture wildcards are (currently)
+                       # always hypenated.
+                       if ($a !~ /-/) {
+                               return 1 if $arch eq $a;
+                       }
+                       elsif (exists $knownsame{$arch}{$a}) {
+                               return 1 if $knownsame{$arch}{$a};
+                       }
+                       elsif (system("dpkg-architecture", "-a$arch", "-i$a") == 0) {
+                               return $knownsame{$arch}{$a}=1;
+                       }
+                       else {
+                               $knownsame{$arch}{$a}=0;
+                       }
+               }
+       
+               return 0;
        }
-
-       return 0;
 }
 
 # Returns source package name
index 970d764437a1cc0d02e23422b3fcf92af97650a0..23f76c8be1280839d4455cc38e7b917808367bb9 100644 (file)
@@ -1,3 +1,11 @@
+debhelper (7.4.19) UNRELEASED; urgency=low
+
+  * Memoize architecture comparisons in samearch, and avoid calling
+    dpkg-architecture at all for simple comparisons not involving
+    architecture wildcards. Closes:# 579317
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 26 Apr 2010 19:35:53 -0400
+
 debhelper (7.4.18) unstable; urgency=low
 
   * dh_gconf: Depend on new gconf2 that uses triggers, and stop