[debhelper-devel] [debhelper] 01/01: Avoid calling dpkg-architecture on each unknown value
Niels Thykier
nthykier at moszumanska.debian.org
Sat Feb 18 21:05:43 UTC 2017
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository debhelper.
commit 6b05acdf097f3ff8c0e82f641c160f4f6ca29f67
Author: Niels Thykier <niels at thykier.net>
Date: Sat Feb 18 21:00:16 2017 +0000
Avoid calling dpkg-architecture on each unknown value
Call dpkg-architecture at most once (per process) - even if
dpkg_architecture_value() is passed unknown variables.
Signed-off-by: Niels Thykier <niels at thykier.net>
---
Debian/Debhelper/Dh_Lib.pm | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index aa7eaf1..1d2bde1 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -855,15 +855,18 @@ sub excludefile {
return $ENV{$var};
}
elsif (! exists($dpkg_arch_output{$var})) {
- local $_;
- open(PIPE, '-|', 'dpkg-architecture')
+ # Return here if we already consulted dpkg-architecture
+ # (saves a fork+exec on unknown variables)
+ return if %dpkg_arch_output;
+
+ open(my $fd, '-|', 'dpkg-architecture')
or error("dpkg-architecture failed");
- while (<PIPE>) {
- chomp;
- my ($k, $v) = split(/=/, $_, 2);
+ while (my $line = <$fd>) {
+ chomp($line);
+ my ($k, $v) = split(/=/, $line, 2);
$dpkg_arch_output{$k} = $v;
}
- close(PIPE);
+ close($fd);
}
return $dpkg_arch_output{$var};
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git
More information about the debhelper-devel
mailing list