diff options
| author | David Kalnischkies <david@kalnischkies.de> | 2022-04-01 13:45:09 +0200 |
|---|---|---|
| committer | David Kalnischkies <david@kalnischkies.de> | 2022-04-01 14:16:19 +0200 |
| commit | 472376be6818b5ea43250abcbecfcab53b4a729a (patch) | |
| tree | 892879ac883236b867e058a82b7ca153b3c56fc4 /apt-pkg/deb/debrecords.cc | |
| parent | 0b156cd1711a5e27643b941f5a321a62e5a9b628 (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/debrecords.cc')
| -rw-r--r-- | apt-pkg/deb/debrecords.cc | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index 8fb17ae0b..e2ffaefff 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -16,6 +16,7 @@ #include <apt-pkg/fileutl.h> #include <apt-pkg/pkgcache.h> #include <apt-pkg/strutl.h> +#include <apt-pkg/tagfile-keys.h> #include <apt-pkg/tagfile.h> #include <algorithm> @@ -57,13 +58,13 @@ debRecordParserBase::debRecordParserBase() : Parser(), d(NULL) {} // RecordParserBase::FileName - Return the archive filename on the site /*{{{*/ string debRecordParserBase::FileName() { - return Section.FindS("Filename"); + return Section.Find(pkgTagSection::Key::Filename).to_string(); } /*}}}*/ // RecordParserBase::Name - Return the package name /*{{{*/ string debRecordParserBase::Name() { - string Result = Section.FindS("Package"); + auto Result = Section.Find(pkgTagSection::Key::Package).to_string(); // Normalize mixed case package names to lower case, like dpkg does // See Bug#807012 for details @@ -75,7 +76,7 @@ string debRecordParserBase::Name() // RecordParserBase::Homepage - Return the package homepage /*{{{*/ string debRecordParserBase::Homepage() { - return Section.FindS("Homepage"); + return Section.Find(pkgTagSection::Key::Homepage).to_string(); } /*}}}*/ // RecordParserBase::Hashes - return the available archive hashes /*{{{*/ @@ -88,7 +89,7 @@ HashStringList debRecordParserBase::Hashes() const if (hash.empty() == false) hashes.push_back(HashString(*type, hash)); } - auto const size = Section.FindULL("Size", 0); + auto const size = Section.FindULL(pkgTagSection::Key::Size, 0); if (size != 0) hashes.FileSize(size); return hashes; @@ -97,7 +98,7 @@ HashStringList debRecordParserBase::Hashes() const // RecordParserBase::Maintainer - Return the maintainer email /*{{{*/ string debRecordParserBase::Maintainer() { - return Section.FindS("Maintainer"); + return Section.Find(pkgTagSection::Key::Maintainer).to_string(); } /*}}}*/ // RecordParserBase::RecordField - Return the value of an arbitrary field /*{{*/ @@ -134,20 +135,20 @@ string debRecordParserBase::LongDesc(std::string const &lang) break; else if (*l == "en") { - orig = Section.FindS("Description"); + orig = Section.Find(pkgTagSection::Key::Description).to_string(); if (orig.empty() == false) break; } } if (orig.empty() == true) - orig = Section.FindS("Description"); + orig = Section.Find(pkgTagSection::Key::Description).to_string(); } else { std::string const tagname = "Description-" + lang; orig = Section.FindS(tagname.c_str()); if (orig.empty() == true && lang == "en") - orig = Section.FindS("Description"); + orig = Section.Find(pkgTagSection::Key::Description).to_string(); } char const * const codeset = nl_langinfo(CODESET); @@ -165,17 +166,17 @@ static const char * const SourceVerSeparators = " ()"; // RecordParserBase::SourcePkg - Return the source package name if any /*{{{*/ string debRecordParserBase::SourcePkg() { - string Res = Section.FindS("Source"); - string::size_type Pos = Res.find_first_of(SourceVerSeparators); - if (Pos == string::npos) - return Res; - return string(Res,0,Pos); + auto Res = Section.Find(pkgTagSection::Key::Source).to_string(); + auto const Pos = Res.find_first_of(SourceVerSeparators); + if (Pos != std::string::npos) + Res.erase(Pos); + return Res; } /*}}}*/ // RecordParserBase::SourceVer - Return the source version number if present /*{{{*/ string debRecordParserBase::SourceVer() { - string Pkg = Section.FindS("Source"); + auto const Pkg = Section.Find(pkgTagSection::Key::Source).to_string(); string::size_type Pos = Pkg.find_first_of(SourceVerSeparators); if (Pos == string::npos) return ""; |
