summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2022-03-28 18:05:44 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2022-04-01 14:16:19 +0200
commit0b156cd1711a5e27643b941f5a321a62e5a9b628 (patch)
tree53b26d4b87c6a41c6e65d419b85676c0fe9c15de
parentba95ef53cf09b7f45c2ef9a39c0c158b7d79a88e (diff)
Avoid .c_str() on strings feed into pkgTagSection::FindS
FindS has a APT::StringView based API nowadays, so we can avoid these explicit calls also allowing us to avoid the std::string in input or output entirely or at least move it a few branches down.
-rw-r--r--apt-pkg/acquire-item.cc18
-rw-r--r--apt-pkg/deb/debrecords.cc2
-rw-r--r--apt-pkg/edsp.cc2
-rw-r--r--apt-pkg/tagfile.cc4
4 files changed, 13 insertions, 13 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index f9362b0d5..d9e1e516b 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -2371,13 +2371,13 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
{
std::string tagname = *type;
tagname.append("-Current");
- std::string const tmp = Tags.FindS(tagname.c_str());
+ auto const tmp = Tags.Find(tagname);
if (tmp.empty() == true)
continue;
string hash;
unsigned long long size;
- std::stringstream ss(tmp);
+ std::stringstream ss(tmp.to_string());
ss.imbue(posix);
ss >> hash >> size;
if (unlikely(hash.empty() == true))
@@ -2441,13 +2441,13 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
std::string tagname = *type;
tagname.append("-History");
- std::string const tmp = Tags.FindS(tagname.c_str());
+ auto const tmp = Tags.Find(tagname);
if (tmp.empty() == true)
continue;
string hash, filename;
unsigned long long size;
- std::stringstream ss(tmp);
+ std::stringstream ss(tmp.to_string());
ss.imbue(posix);
while (ss >> hash >> size >> filename)
@@ -2498,13 +2498,13 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
std::string tagname = *type;
tagname.append("-Patches");
- std::string const tmp = Tags.FindS(tagname.c_str());
+ auto const tmp = Tags.Find(tagname);
if (tmp.empty() == true)
continue;
string hash, filename;
unsigned long long size;
- std::stringstream ss(tmp);
+ std::stringstream ss(tmp.to_string());
ss.imbue(posix);
while (ss >> hash >> size >> filename)
@@ -2536,13 +2536,13 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
{
std::string tagname = *type;
tagname.append("-Download");
- std::string const tmp = Tags.FindS(tagname.c_str());
+ auto const tmp = Tags.Find(tagname);
if (tmp.empty() == true)
continue;
string hash, filename;
unsigned long long size;
- std::stringstream ss(tmp);
+ std::stringstream ss(tmp.to_string());
ss.imbue(posix);
// FIXME: all of pdiff supports only .gz compressed patches
@@ -2613,7 +2613,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
if (pdiff_merge == true)
{
// reprepro and dak add this flag if they merge patches on the server
- std::string const precedence = Tags.FindS("X-Patch-Precedence");
+ auto const precedence = Tags.Find("X-Patch-Precedence");
pdiff_merge = (precedence != "merged");
}
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index 22ac219ba..8fb17ae0b 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -129,7 +129,7 @@ string debRecordParserBase::LongDesc(std::string const &lang)
l != lang.end(); ++l)
{
std::string const tagname = "Description-" + *l;
- orig = Section.FindS(tagname.c_str());
+ orig = Section.FindS(tagname);
if (orig.empty() == false)
break;
else if (*l == "en")
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index b7c0d28d2..6493a4595 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -453,7 +453,7 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres
continue;
}
- decltype(VersionCount) const id = section.FindULL(type.c_str(), VersionCount);
+ decltype(VersionCount) const id = section.FindULL(type, VersionCount);
if (id == VersionCount) {
_error->Warning("Unable to parse %s request with id value '%s'!", type.c_str(), section.FindS(type.c_str()).c_str());
continue;
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 52000c6b9..ebad1a4c5 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -1051,8 +1051,8 @@ bool pkgTagSection::Write(FileFd &File, char const * const * const Order, std::v
{
if (R->Action == Tag::REMOVE)
continue;
- std::string const name = ((R->Action == Tag::RENAME) ? R->Data : R->Name);
- if (Exists(name.c_str()))
+ auto const name = ((R->Action == Tag::RENAME) ? R->Data : R->Name);
+ if (Exists(name))
continue;
if (Order != NULL)
{