From 0d3c61deb475b1fd731bfea5d8d47a4574db8c7b Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Fri, 23 Nov 2007 22:41:29 +0100 Subject: [PATCH] dpkg-shlibdeps: optimize "dpkg -S" lookups by caching results --- ChangeLog | 6 ++++++ debian/changelog | 3 +++ scripts/dpkg-shlibdeps.pl | 17 +++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93b370bc..d62de5a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-11-23 Raphael Hertzog + + * scripts/dpkg-shlibdeps.pl: Apply patch from Aaron M. Ucko + to optimize "dpkg -S" lookups by caching + results. + 2007-11-23 Raphael Hertzog * scripts/dpkg-shlibdeps.pl: Limit the number of warnings diff --git a/debian/changelog b/debian/changelog index 3634d4b5..02f82aea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,14 @@ dpkg (1.14.11) UNRELEASED; urgency=low + [ Raphael Hertzog ] * dpkg-shlibdeps now ignores the lack of dependency information in some specific cases (instead of failing): - when the library is in the same package than the binary analyzed - when the library is not versionned and can't have a shlibs file * dpkg-shlibdeps now only displays 10 warnings about symbols not found for each binary and a count of skipped warnings. Closes: #452318 + * dpkg-shlibdeps: optimize "dpkg -S" lookups by caching results, patch + from Aaron M. Ucko . Closes: #452577 -- Guillem Jover Fri, 23 Nov 2007 06:50:02 +0200 diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index fa81c236..438eaace 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -518,9 +518,22 @@ sub my_find_library { return undef; } +my %cached_pkgmatch = (); + sub find_packages { - my @files = (@_); + my @files; my $pkgmatch = {}; + + foreach (@_) { + if (exists $cached_pkgmatch{$_}) { + $pkgmatch->{$_} = $cached_pkgmatch{$_}; + } else { + push @files, $_; + $cached_pkgmatch{$_} = [""]; # placeholder to cache misses too. + } + } + return $pkgmatch unless scalar(@files); + my $pid = open(DPKG, "-|"); syserr(_g("cannot fork for dpkg --search")) unless defined($pid); if (!$pid) { @@ -538,7 +551,7 @@ sub find_packages { print(STDERR " $_\n") || syserr(_g("write diversion info to stderr")); } elsif (m/^([^:]+): (\S+)$/) { - $pkgmatch->{$2} = [ split(/, /, $1) ]; + $cached_pkgmatch{$2} = $pkgmatch->{$2} = [ split(/, /, $1) ]; } else { warning(_g("unknown output from dpkg --search: '%s'"), $_); } -- 2.39.5