From ea6ba7479b984b770df7f9325ab6035e1a2f5b13 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 26 Apr 2010 19:45:04 -0400 Subject: [PATCH] Memoize architecture comparisons in samearch, and avoid calling dpkg-architecture at all for simple comparisons not involving architecture wildcards. Closes:# 579317 --- Debian/Debhelper/Dh_Lib.pm | 33 ++++++++++++++++++++++++++------- debian/changelog | 8 ++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm index d9c1d38..421dd99 100644 --- a/Debian/Debhelper/Dh_Lib.pm +++ b/Debian/Debhelper/Dh_Lib.pm @@ -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 diff --git a/debian/changelog b/debian/changelog index 970d764..23f76c8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 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 -- 2.39.5