Comment 10 for bug 165181

Revision history for this message
Michael Vogt (mvo) wrote :

A fix could look something like this (this is just a prototype). This changes sort time to 1.5s (from 59,5s). Ideally we would do that in apt itself, having some more smartness there.

=== modified file 'common/rpackage.cc'
--- common/rpackage.cc 2010-01-25 10:17:45 +0000
+++ common/rpackage.cc 2010-02-17 10:30:48 +0000
@@ -744,6 +744,9 @@
 }

 #ifdef WITH_APT_AUTH
+std::map<pkgCache::PkgFileIterator, pkgIndexFile*> trust_cache;
+std::map<pkgCache::PkgFileIterator, pkgIndexFile*>::iterator it;
+
 bool RPackage::isTrusted()
 {
    pkgCache::VerIterator Ver;
@@ -757,17 +760,24 @@
    for (pkgCache::VerFileIterator i = Ver.FileList(); i.end() == false; i++)
    {
       pkgIndexFile *Index;
- if (Sources->FindIndex(i.File(),Index) == false)
- continue;
+ it = trust_cache.find(i.File());
+ if (it == trust_cache.end()) {
+ if (Sources->FindIndex(i.File(),Index) == false)
+ continue;
+ } else {
+ Index = (*it).second;
+ }
+ trust_cache.insert( pair<pkgCache::PkgFileIterator, pkgIndexFile*>(i.File
(), Index) );
+
       if (_config->FindB("Debug::pkgAcquire::Auth", false))
       {
          std::cerr << "Checking index: " << Index->Describe()
                    << "(Trusted=" << Index->IsTrusted() << ")\n";
       }
- if (Index->IsTrusted())
+ if (Index->IsTrusted()) {
          return true;
+ }
    }
-
    return false;
 }
 #else