summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/deblistparser.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2022-04-01 13:45:09 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2022-04-01 14:16:19 +0200
commit472376be6818b5ea43250abcbecfcab53b4a729a (patch)
tree892879ac883236b867e058a82b7ca153b3c56fc4 /apt-pkg/deb/deblistparser.cc
parent0b156cd1711a5e27643b941f5a321a62e5a9b628 (diff)
Use pkgTagSection::Key in more places in src:apt
The speed critical paths were converted earlier, but the remaining could benefit a tiny bit from this as well especially as we have the facility now available and can therefore brush up the code in various places in the process as well. Also takes the time to add the hidden Exists method advertised in the headers, but previously not implemented.
Diffstat (limited to 'apt-pkg/deb/deblistparser.cc')
-rw-r--r--apt-pkg/deb/deblistparser.cc21
1 files changed, 10 insertions, 11 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index a1247dd98..6f47053a5 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -126,7 +126,7 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/
{
if (showErrors == true)
_error->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
- Section.FindS("Package").c_str());
+ Package().c_str());
MA = pkgCache::Version::No;
}
else
@@ -140,7 +140,7 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/
{
if (showErrors == true)
_error->Warning("Unknown Multi-Arch type '%s' for package '%s'",
- MultiArch.to_string().c_str(), Section.FindS("Package").c_str());
+ MultiArch.to_string().c_str(), Package().c_str());
MA = pkgCache::Version::No;
}
@@ -256,21 +256,20 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
// ListParser::AvailableDescriptionLanguages /*{{{*/
std::vector<std::string> debListParser::AvailableDescriptionLanguages()
{
- std::vector<std::string> const understood = APT::Configuration::getLanguages(true);
std::vector<std::string> avail;
static constexpr int prefixLen = 12;
char buf[32] = "Description-";
- if (Section.Exists("Description") == true)
- avail.push_back("");
- for (std::vector<std::string>::const_iterator lang = understood.begin(); lang != understood.end(); ++lang)
+ if (Section.Exists(pkgTagSection::Key::Description))
+ avail.emplace_back();
+ for (auto const &lang : APT::Configuration::getLanguages(true))
{
- if (unlikely(lang->size() > sizeof(buf) - prefixLen)) {
- _error->Warning("Ignoring translated description %s", lang->c_str());
+ if (unlikely(lang.size() > sizeof(buf) - prefixLen)) {
+ _error->Warning("Ignoring translated description %s", lang.c_str());
continue;
}
- memcpy(buf + prefixLen, lang->c_str(), lang->size());
- if (Section.Exists(StringView(buf, prefixLen + lang->size())) == true)
- avail.push_back(*lang);
+ memcpy(buf + prefixLen, lang.c_str(), lang.size());
+ if (Section.Exists(StringView(buf, prefixLen + lang.size())) == true)
+ avail.push_back(lang);
}
return avail;
}