diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2010-03-18 18:51:14 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2010-03-18 18:51:14 +0100 |
commit | 8d4c859d0d20687a8ffcf9e1d60466d061c2e24d (patch) | |
tree | 46e6fdd05df63623dad398972d7d84294619a6d8 /apt-pkg/pkgcache.cc | |
parent | 306eacf617b8ea8c87b31258c55a5373be4ad946 (diff) |
Readd the FindPkg() method implementation used in the singleArch days to
use it as a fallback if multiarch is not enabled. The effect is barly
noticeable but SingleArch is the realworld scenario.
Diffstat (limited to 'apt-pkg/pkgcache.cc')
-rw-r--r-- | apt-pkg/pkgcache.cc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 24d9e0329..fe8757ded 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -108,6 +108,7 @@ bool pkgCache::Header::CheckSizes(Header &Against) const /* */ pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map) { + MultiArchEnabled = APT::Configuration::getArchitectures().size() > 1; if (DoMap == true) ReMap(); } @@ -179,10 +180,30 @@ unsigned long pkgCache::sHash(const char *Str) const } /*}}}*/ +// Cache::SingleArchFindPkg - Locate a package by name /*{{{*/ +// --------------------------------------------------------------------- +/* Returns 0 on error, pointer to the package otherwise + The multiArch enabled methods will fallback to this one as it is (a bit) + faster for single arch environments and realworld is mostly singlearch… */ +pkgCache::PkgIterator pkgCache::SingleArchFindPkg(const string &Name) +{ + // Look at the hash bucket + Package *Pkg = PkgP + HeaderP->PkgHashTable[Hash(Name)]; + for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage) + { + if (Pkg->Name != 0 && StrP[Pkg->Name] == Name[0] && + stringcasecmp(Name,StrP + Pkg->Name) == 0) + return PkgIterator(*this,Pkg); + } + return PkgIterator(*this,0); +} + /*}}}*/ // Cache::FindPkg - Locate a package by name /*{{{*/ // --------------------------------------------------------------------- /* Returns 0 on error, pointer to the package otherwise */ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) { + if (MultiArchCache() == false) + return SingleArchFindPkg(Name); size_t const found = Name.find(':'); if (found == string::npos) return FindPkg(Name, "native"); @@ -195,7 +216,14 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) { // Cache::FindPkg - Locate a package by name /*{{{*/ // --------------------------------------------------------------------- /* Returns 0 on error, pointer to the package otherwise */ -pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string Arch) { +pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) { + if (MultiArchCache() == false) { + if (Arch == "native" || Arch == "all" || + Arch == _config->Find("APT::Architecture")) + return SingleArchFindPkg(Name); + else + return PkgIterator(*this,0); + } /* We make a detour via the GrpIterator here as on a multi-arch environment a group is easier to find than a package (less entries in the buckets) */ |