diff options
author | Raphael Geissert <geissert@debian.org> | 2017-10-05 10:31:07 +0000 |
---|---|---|
committer | Raphael Geissert <geissert@debian.org> | 2017-10-05 10:31:07 +0000 |
commit | 7bcad46051af1cff06ed9f723ba57845b5f4db25 (patch) | |
tree | ac1da71affa1d005538baaa9c94c610e1445ea12 /bin/check-new-issues | |
parent | 6f3a2d685ce43155d826d6fa177cbc5b869f2a81 (diff) |
Cache the latest apt-cache results to speed things up
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@56426 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'bin/check-new-issues')
-rwxr-xr-x | bin/check-new-issues | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/bin/check-new-issues b/bin/check-new-issues index 760d29b614..99699f70a8 100755 --- a/bin/check-new-issues +++ b/bin/check-new-issues @@ -411,7 +411,7 @@ sub auto_search { my $prog_esc =$prog; $prog_esc =~ tr{a-zA-Z0-9_@/-}{ }cs; print "doing apt-cache search..."; - my @ac=`apt-cache search $prog_esc`; + my @ac=apt_cache($prog_esc); if (scalar @ac > $auto_display_limit || scalar @ac == 0) { print "\r", scalar @ac, " results from apt-cache search $prog_esc\n"; } @@ -457,6 +457,24 @@ sub auto_search { } } +{ + my @apt_cache_cache; + my $apt_cache_cache_term; + + sub apt_cache { + my $term = shift; + + if ($term eq $apt_cache_cache_term) { + return @apt_cache_cache; + } + + @apt_cache_cache = `apt-cache search $term`; + $apt_cache_cache_term = $term; + + return @apt_cache_cache; + } +} + sub read_embedded_copies { my $emb_file = $opts{e} || "$basedir/data/embedded-code-copies"; open(my $fh, $emb_file); |