diff options
author | Joey Hess <joey@kitenet.net> | 2010-04-26 19:45:04 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-04-26 19:45:04 -0400 |
commit | ea6ba7479b984b770df7f9325ab6035e1a2f5b13 (patch) | |
tree | 072cf518428cecab0f3a4ba48b2e2278d40e99da /Debian/Debhelper/Dh_Lib.pm | |
parent | e74b1d8fa271f761ffbfda8207806b2a153735b7 (diff) |
Memoize architecture comparisons in samearch, and avoid calling dpkg-architecture at all for simple comparisons not involving architecture wildcards. Closes:# 579317
Diffstat (limited to 'Debian/Debhelper/Dh_Lib.pm')
-rw-r--r-- | Debian/Debhelper/Dh_Lib.pm | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm index d9c1d389..421dd996 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 |