From 25594bb5bddc031afc4d62f3164cd9116d778517 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 2 Sep 2014 18:20:49 +0200 Subject: make GetLocalitySortedVersionSet more generic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No reason in and of by itself at the moment, but prepares for the goal of having 'apt search' and 'apt-cache search' using the same code now that they at least support the same stuff. The 'apt' code is just a multitude slower at the moment… Git-Dch: Ignore --- apt-private/private-search.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'apt-private/private-search.cc') diff --git a/apt-private/private-search.cc b/apt-private/private-search.cc index 5e12902e8..6bce9ffa4 100644 --- a/apt-private/private-search.cc +++ b/apt-private/private-search.cc @@ -63,7 +63,7 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/ LocalitySortedVersionSet bag; OpTextProgress progress(*_config); progress.OverallProgress(0, 100, 50, _("Sorting")); - GetLocalitySortedVersionSet(CacheFile, bag, progress); + GetLocalitySortedVersionSet(CacheFile, &bag, &progress); LocalitySortedVersionSet::iterator V = bag.begin(); progress.OverallProgress(50, 100, 50, _("Full Text Search")); @@ -77,6 +77,7 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/ format += " ${LongDescription}\n"; int Done = 0; + std::vector PkgsDone(Cache->Head().PackageCount, false); for ( ;V != bag.end(); ++V) { if (Done%500 == 0) @@ -84,10 +85,11 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/ ++Done; // we want to list each package only once - char const * const PkgName = V.ParentPkg().Name(); - if (output_map.find(PkgName) != output_map.end()) + pkgCache::PkgIterator const P = V.ParentPkg(); + if (PkgsDone[P->ID] == true) continue; + char const * const PkgName = P.Name(); pkgCache::DescIterator Desc = V.TranslatedDescription(); pkgRecords::Parser &parser = records.Lookup(Desc.FileList()); std::string const LongDesc = parser.LongDesc(); @@ -106,10 +108,11 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/ } if (all_found == true) { - std::stringstream outs; - ListSingleVersion(CacheFile, records, V, outs, format); - output_map.insert(std::make_pair( - PkgName, outs.str())); + PkgsDone[P->ID] = true; + std::stringstream outs; + ListSingleVersion(CacheFile, records, V, outs, format); + output_map.insert(std::make_pair( + PkgName, outs.str())); } } APT_FREE_PATTERNS(); -- cgit v1.2.3