From d0c2cc03d75fa66986a9aadf8b1361426e9ceb4d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 30 Jan 2025 21:45:40 +0000 Subject: Do not create descriptions structs for each architecture The architectures are supposed to share the descriptions as they are (very usually) the same, but the code was happily creating structs for every architecture of a package which is especially pointless as for e.g. Debian those will be the short description likely superseded in output and all uses by the 'en' "translation". --- apt-pkg/pkgcachegen.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 055b2e08e..de04d1313 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -513,23 +513,26 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator a version with a description of the same MD5 - if so we reuse this description group instead of creating our own for this version */ for (pkgCache::PkgIterator P = Grp.PackageList(); - P.end() == false; P = Grp.NextPkg(P)) + not P.end() && Ver->DescriptionList == 0; P = Grp.NextPkg(P)) { - for (pkgCache::VerIterator V = P.VersionList(); - V.end() == false; ++V) + for (pkgCache::VerIterator V = P.VersionList(); not V.end(); ++V) { if (V->DescriptionList == 0 || Cache.ViewString(V.DescriptionList()->md5sum) != CurMd5) continue; Ver->DescriptionList = V->DescriptionList; + break; } } // We haven't found reusable descriptions, so add the first description(s) map_stringitem_t md5idx = Ver->DescriptionList == 0 ? 0 : Ver.DescriptionList()->md5sum; - std::vector availDesc = List.AvailableDescriptionLanguages(); - for (std::vector::const_iterator CurLang = availDesc.begin(); CurLang != availDesc.end(); ++CurLang) - if (AddNewDescription(List, Ver, *CurLang, CurMd5, md5idx) == false) + for (auto const &CurLang : List.AvailableDescriptionLanguages()) + { + if (Ver->DescriptionList != 0 && IsDuplicateDescription(Cache, Ver.DescriptionList(), CurMd5, CurLang)) + continue; + if (not AddNewDescription(List, Ver, CurLang, CurMd5, md5idx)) return false; + } return true; } /*}}}*/ -- cgit v1.2.3-70-g09d2