Author: geissert
Date: 2017-10-05 10:31:07 +0000 (Thu, 05 Oct 2017)
New Revision: 56426

Modified:
   bin/check-new-issues
Log:
Cache the latest apt-cache results to speed things up


Modified: bin/check-new-issues
===================================================================
--- bin/check-new-issues        2017-10-05 10:00:49 UTC (rev 56425)
+++ bin/check-new-issues        2017-10-05 10:31:07 UTC (rev 56426)
@@ -411,7 +411,7 @@
                        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 @@
        }
 }
 
+{
+       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);


_______________________________________________
Secure-testing-commits mailing list
Secure-testing-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/secure-testing-commits

Reply via email to