From 563fedea263361b0786303f58dccc1a9a733e1d9 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 26 Dec 2018 12:40:09 +0100 Subject: debListParser: Avoid native arch lookup in ParseDepends We called low-level ParseDepends without an architecture each time, which means each call looked up the native architecture. Store the native architecture in the class and use that when calling low-level ParseDepends from the high-level ParseDepends(). This improves performance for a cache build from 2.7 to 2.5 seconds for me. Also avoid a call when stripping multiarch, as the native architecture is passed in. --- apt-pkg/deb/deblistparser.cc | 6 +++--- apt-pkg/deb/deblistparser.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index e8dff833d..80ca10e37 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -61,6 +61,7 @@ debListParser::debListParser(FileFd *File) : else forceEssential.emplace_back("apt"); forceImportant = _config->FindVector("pkgCacheGen::ForceImportant"); + myArch = _config->Find("APT::Architecture"); } /*}}}*/ // ListParser::Package - Return the package name /*{{{*/ @@ -621,12 +622,11 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, // We don't want to confuse library users which can't handle MultiArch if (StripMultiArch == true) { - string const arch = _config->Find("APT::Architecture"); size_t const found = Package.rfind(':'); if (found != StringView::npos && (Package.substr(found) == ":any" || Package.substr(found) == ":native" || - Package.substr(found +1) == arch)) + Package.substr(found +1) == Arch)) Package = Package.substr(0,found); } @@ -848,7 +848,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver, StringView Version; unsigned int Op; - Start = ParseDepends(Start, Stop, Package, Version, Op, false, false, false); + Start = ParseDepends(Start, Stop, Package, Version, Op, false, false, false, myArch); if (Start == 0) return _error->Error("Problem parsing dependency %zu",static_cast(Key)); // TODO size_t const found = Package.rfind(':'); diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 09b56665f..f02252d58 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -45,6 +45,7 @@ class APT_HIDDEN debListParser : public pkgCacheListParser std::vector forceEssential; std::vector forceImportant; std::string MD5Buffer; + std::string myArch; protected: pkgTagFile Tags; -- cgit v1.2.3