diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-09-08 13:58:55 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-09-14 15:22:18 +0200 |
commit | 8fec289ad8a2c42350c24d5c97b0f104fbbea176 (patch) | |
tree | 8a7bbcf269a55d8aeae83255515709c1e02c300b /apt-pkg | |
parent | 3196dae8e92407b3aa8e12779a8ed7db998ebdc4 (diff) |
remove incorrect optimization branches
These assumptions were once true, but they aren't anymore, so what is
supposed to be a speed up is effectively a slowdown [not that it would
be noticible].
Usage of SingleArchFindPkg was nuked in a stable update already as the
included assumption was actually harmful btw, which is why we should get
right of other 'non-harmful' but still untrue assumptions while we can.
Git-Dch: Ignore
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/pkgcache.cc | 41 | ||||
-rw-r--r-- | apt-pkg/pkgcache.h | 1 |
2 files changed, 6 insertions, 36 deletions
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 11b9b1377..0750a2080 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -217,26 +217,6 @@ map_id_t pkgCache::sHash(const char *Str) const return Hash % HeaderP->GetHashTableSize(); } /*}}}*/ -// 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->PkgHashTableP()[Hash(Name)]; - for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage) - { - int const cmp = strcmp(Name.c_str(), StrP + (GrpP + Pkg->Group)->Name); - if (cmp == 0) - return PkgIterator(*this, Pkg); - else if (cmp < 0) - break; - } - return PkgIterator(*this,0); -} - /*}}}*/ // Cache::FindPkg - Locate a package by name /*{{{*/ // --------------------------------------------------------------------- /* Returns 0 on error, pointer to the package otherwise */ @@ -245,9 +225,9 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) { if (found == string::npos) return FindPkg(Name, "native"); string const Arch = Name.substr(found+1); - /* Beware: This is specialcased to handle pkg:any in dependencies as - these are linked to virtual pkg:any named packages with all archs. - If you want any arch from a given pkg, use FindPkg(pkg,arch) */ + /* Beware: This is specialcased to handle pkg:any in dependencies + as these are linked to virtual pkg:any named packages. + If you want any arch from a pkg, use FindPkg(pkg,"any") */ if (Arch == "any") return FindPkg(Name, "any"); return FindPkg(Name.substr(0, found), Arch); @@ -344,20 +324,11 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const { return PkgIterator(*Owner, 0); /* If we accept any package we simply return the "first" - package in this group (the last one added). */ + package in this group */ if (Arch == "any") return PkgIterator(*Owner, Owner->PkgP + S->FirstPackage); - - char const* const myArch = Owner->NativeArch(); - /* Most of the time the package for our native architecture is - the one we add at first to the cache, but this would be the - last one we check, so we do it now. */ - if (Arch == "native" || Arch == myArch || Arch == "all") { - pkgCache::Package *Pkg = Owner->PkgP + S->LastPackage; - if (strcmp(myArch, Owner->StrP + Pkg->Arch) == 0) - return PkgIterator(*Owner, Pkg); - Arch = myArch; - } + if (Arch == "native" || Arch == "all") + Arch = Owner->NativeArch(); // Iterate over the list to find the matching arch for (pkgCache::Package *Pkg = PackageList(); Pkg != Owner->PkgP; diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index 801f8556d..6f3efd744 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -259,7 +259,6 @@ class pkgCache /*{{{*/ private: void * const d; bool MultiArchEnabled; - APT_HIDDEN PkgIterator SingleArchFindPkg(const std::string &Name); }; /*}}}*/ // Header structure /*{{{*/ |