// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcachegen.cc,v 1.28 1999/02/08 07:30:49 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.34 1999/04/04 01:33:09 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
#include <apt-pkg/configuration.h>
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/strutl.h>
+#include <system.h>
#include <sys/stat.h>
#include <unistd.h>
Cache.HeaderP->Dirty = true;
Map.Sync(0,sizeof(pkgCache::Header));
Map.UsePools(*Cache.HeaderP->Pools,sizeof(Cache.HeaderP->Pools)/sizeof(Cache.HeaderP->Pools[0]));
+ memset(UniqHash,0,sizeof(UniqHash));
}
/*}}}*/
// CacheGenerator::~pkgCacheGenerator - Destructor /*{{{*/
{
List.Owner = this;
- int Counter = 0;
+ unsigned int Counter = 0;
while (List.Step() == true)
{
// Get a pointer to the package structure
// Probe the reverse dependency list for a version string that matches
if (Version.empty() == false)
{
- for (pkgCache::DepIterator I = Pkg.RevDependsList(); I.end() == false; I++)
+/* for (pkgCache::DepIterator I = Pkg.RevDependsList(); I.end() == false; I++, Hit++)
if (I->Version != 0 && I.TargetVer() == Version)
- Dep->Version = I->Version;
+ Dep->Version = I->Version;*/
if (Dep->Version == 0)
if ((Dep->Version = WriteString(Version)) == 0)
return false;
/* Link it to the version (at the end of the list)
Caching the old end point speeds up generation substantially */
- static pkgCache::VerIterator OldVer(Cache);
- static __apt_ptrloc *OldLast;
- if (OldVer != Ver)
+ if (OldDepVer != Ver)
{
- OldLast = &Ver->DependsList;
+ OldDepLast = &Ver->DependsList;
for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++)
- OldLast = &D->NextDepends;
- OldVer = Ver;
+ OldDepLast = &D->NextDepends;
+ OldDepVer = Ver;
}
- Dep->NextDepends = *OldLast;
- *OldLast = Dep.Index();
- OldLast = &Dep->NextDepends;
+ Dep->NextDepends = *OldDepLast;
+ *OldDepLast = Dep.Index();
+ OldDepLast = &Dep->NextDepends;
return true;
}
unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
unsigned int Size)
{
+ /* We use a very small transient hash table here, this speeds up generation
+ by a fair amount on slower machines */
+ pkgCache::StringItem *&Bucket = UniqHash[(S[0]*5 + S[1]) % _count(UniqHash)];
+ if (Bucket != 0 &&
+ stringcmp(S,S+Size,Cache.StrP + Bucket->String) == 0)
+ return Bucket->String;
+
// Search for an insertion point
pkgCache::StringItem *I = Cache.StringItemP + Cache.HeaderP->StringList;
int Res = 1;
// Match
if (Res == 0)
+ {
+ Bucket = I;
return I->String;
+ }
// Get a structure
unsigned long Item = Map.Allocate(sizeof(pkgCache::StringItem));
if (ItemP->String == 0)
return 0;
+ Bucket = ItemP;
return ItemP->String;
}
/*}}}*/
int Missing = 0;
for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++)
{
+ // Only cache deb source types.
+ if (I->Type != pkgSourceList::Item::Deb)
+ {
+ Missing++;
+ continue;
+ }
+
string File = ListDir + URItoFileName(I->PackagesURI());
struct stat Buf;
if (stat(File.c_str(),&Buf) != 0)
Missing++;
}
}
-
+
// Open the source package cache
if (FileExists(CacheFile) == false)
return false;
return false;
for (pkgCache::PkgFileIterator F(Cache); F.end() == false; F++)
- {
+ {
// Search for a match in the source list
bool Bad = true;
for (pkgSourceList::const_iterator I = List.begin();
I != List.end(); I++)
{
+ // Only cache deb source types.
+ if (I->Type != pkgSourceList::Item::Deb)
+ continue;
+
string File = ListDir + URItoFileName(I->PackagesURI());
if (F.FileName() == File)
{
string CacheFile = _config->FindFile("Dir::Cache::pkgcache");
bool SrcOk = pkgSrcCacheCheck(List);
bool PkgOk = SrcOk && pkgPkgCacheCheck(CacheFile);
-
+
// Rebuild the source and package caches
if (SrcOk == false)
{
unsigned long CurrentSize = 0;
for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++)
{
+ // Only cache deb source types.
+ if (I->Type != pkgSourceList::Item::Deb)
+ continue;
+
string File = ListDir + URItoFileName(I->PackagesURI());
if (FileExists(File) == false)