X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/34e8a998eb9e4f75f989acc6f8b9db8010e56b7c..c67dc114eafe034b8223ce3df6474f7c25f150a8:/apt-pkg/pkgcachegen.cc?ds=sidebyside diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 3d1a654d1..8187b3950 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -189,17 +189,22 @@ bool pkgCacheGenerator::MergeList(ListParser &List, pkgCache::VerIterator Ver = Pkg.VersionList(); map_ptrloc *LastVer = &Pkg->VersionList; int Res = 1; + unsigned long const Hash = List.VersionHash(); for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) { Res = Cache.VS->CmpVersion(Version,Ver.VerStr()); - if (Res >= 0) + // Version is higher as current version - insert here + if (Res > 0) break; + // Versionstrings are equal - is hash also equal? + if (Res == 0 && Ver->Hash == Hash) + break; + // proceed with the next till we have either the right + // or we found another version (which will be lower) } - - /* We already have a version for this item, record that we - saw it */ - unsigned long Hash = List.VersionHash(); - if (Res == 0 && Ver->Hash == Hash) + + /* We already have a version for this item, record that we saw it */ + if (Res == 0 && Ver.end() == false && Ver->Hash == Hash) { if (List.UsePackage(Pkg,Ver) == false) return _error->Error(_("Error occurred while processing %s (UsePackage2)"), @@ -218,17 +223,6 @@ bool pkgCacheGenerator::MergeList(ListParser &List, } continue; - } - - // Skip to the end of the same version set. - if (Res == 0) - { - for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) - { - Res = Cache.VS->CmpVersion(Version,Ver.VerStr()); - if (Res != 0) - break; - } } // Add a new version