summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorHerman Semenoff <GermanAizek@yandex.ru>2026-04-08 11:37:24 +0300
committerHerman Semenoff <GermanAizek@yandex.ru>2026-04-08 11:37:24 +0300
commitaf5b9453a1908021cf75c348522c1a12eeb0dee4 (patch)
treee5d3d569e51d24207eb0228615f5eedd37e08296 /apt-pkg
parent04dcfd52355ca06143a8aaca4afd718a22fb0ded (diff)
apt: funcs called with a string literal consisting of a single character
Benchmark: - https://stackoverflow.com/questions/62058906/why-my-performance-benchmark-gives-me-wrong-results References: - https://clang.llvm.org/extra/clang-tidy/checks/performance/prefer-single-char-overloads.html
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc6
-rw-r--r--apt-pkg/acquire-worker.cc6
-rw-r--r--apt-pkg/aptconfiguration.cc6
-rw-r--r--apt-pkg/cdrom.cc2
-rw-r--r--apt-pkg/contrib/strutl.cc4
-rw-r--r--apt-pkg/deb/debmetaindex.cc2
-rw-r--r--apt-pkg/deb/dpkgpm.cc4
-rw-r--r--apt-pkg/indexcopy.cc2
8 files changed, 16 insertions, 16 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 8bd77c052..21ed7b242 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -477,7 +477,7 @@ bool pkgAcqTransactionItem::QueueURI(pkgAcquire::ItemDesc &Item)
if (unlikely(TargetHash == nullptr))
return false;
::URI uri{U};
- auto const trailing_slash = uri.Path.find_last_of("/");
+ auto const trailing_slash = uri.Path.find_last_of('/');
if (unlikely(trailing_slash == std::string::npos))
return false;
auto altPath = uri.Path.substr(0, trailing_slash) + "/by-hash/" + TargetHash->HashType() + "/" + TargetHash->HashValue();
@@ -495,8 +495,8 @@ bool pkgAcqTransactionItem::QueueURI(pkgAcquire::ItemDesc &Item)
if (SameMirrorURI.empty() == false)
{
UsedMirror = TransactionManager->UsedMirror;
- if (Item.Description.find(" ") != string::npos)
- Item.Description.replace(0, Item.Description.find(" "), UsedMirror);
+ if (Item.Description.find(' ') != string::npos)
+ Item.Description.replace(0, Item.Description.find(' '), UsedMirror);
}
return pkgAcquire::Item::QueueURI(Item);
}
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 55897945c..d712f3e30 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -231,7 +231,7 @@ static void APT_NONNULL(3) ChangeSiteIsMirrorChange(std::string const &NewURI, p
if (URI::SiteOnly(NewURI) == URI::SiteOnly(desc.URI))
return;
- auto const firstSpace = desc.Description.find(" ");
+ auto const firstSpace = desc.Description.find(' ');
if (firstSpace != std::string::npos)
{
std::string const OldSite = desc.Description.substr(0, firstSpace);
@@ -277,8 +277,8 @@ bool pkgAcquire::Worker::RunMessages()
for (pkgAcquire::Queue::QItem::owner_iterator O = Itm->Owners.begin(); O != Itm->Owners.end(); ++O)
(*O)->UsedMirror = UsedMirror;
- if (Itm->Description.find(" ") != string::npos)
- Itm->Description.replace(0, Itm->Description.find(" "), UsedMirror);
+ if (Itm->Description.find(' ') != string::npos)
+ Itm->Description.replace(0, Itm->Description.find(' '), UsedMirror);
}
}
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index a0164c6c3..fb6bcdb6d 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -175,8 +175,8 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
builtin.push_back("none");
for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) {
string const name = SubstVar(Ent->d_name, "%5f", "_");
- size_t const foundDash = name.rfind("-");
- size_t const foundUnderscore = name.rfind("_", foundDash);
+ size_t const foundDash = name.rfind('-');
+ size_t const foundUnderscore = name.rfind('_', foundDash);
if (foundDash == string::npos || foundUnderscore == string::npos ||
foundDash <= foundUnderscore ||
name.substr(foundUnderscore+1, foundDash-(foundUnderscore+1)) != "Translation")
@@ -692,7 +692,7 @@ std::string Configuration::color(std::string const &colorName, std::string const
// | \\x1B<word> ; color escaped.
// | <word> ; a simple color name
// | <color> <color> ; a sequence of colors
- if (color.find(" ") != color.npos)
+ if (color.find(' ') != color.npos)
{
std::string res;
for (auto &&colorPart : VectorizeString(color, ' '))
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index 4da2b738d..6d7613100 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -262,7 +262,7 @@ bool pkgCdrom::DropBinaryArch(vector<string> &List)
// Between Start and End is the architecture
Start += 8;
- if ((End = strstr(Start,"/")) != 0 && Start != End &&
+ if ((End = strchr(Start,'/')) != 0 && Start != End &&
APT::Configuration::checkArchitecture(string(Start, End)) == true)
continue; // okay, architecture is accepted
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index b5200831a..4363ab818 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -840,7 +840,7 @@ std::string LookupTag(const std::string &Message, const char *TagC, const char *
// skip the space leading a multiline (Keep all other whitespaces in the value)
valuestart = std::next(valuestart);
}
- auto const valueend = result.find_last_not_of("\n");
+ auto const valueend = result.find_last_not_of('\n');
if (valueend == std::string::npos)
result.clear();
else
@@ -1506,7 +1506,7 @@ char *safe_snprintf(char *Buffer,char *End,const char *Format,...)
// ---------------------------------------------------------------------
string StripEpoch(const string &VerStr)
{
- size_t i = VerStr.find(":");
+ size_t i = VerStr.find(':');
if (i == string::npos)
return VerStr;
return VerStr.substr(i+1);
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index b85163654..8fcb83678 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -1318,7 +1318,7 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
/// allows you to match a.b.c against itself, .b.c, and .c, but not b.c
static inline std::string NextLevelDomain(std::string Host)
{
- auto nextDot = Host.find(".", 1);
+ auto nextDot = Host.find('.', 1);
if (nextDot == Host.npos)
return "";
return Host.substr(nextDot);
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 0f2467607..395227f50 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -646,7 +646,7 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
}
// At this point we have a pkgname, but it might not be arch-qualified !
- if (pkgname.find(":") == std::string::npos)
+ if (pkgname.find(':') == std::string::npos)
{
pkgCache::GrpIterator const Grp = Cache.FindGrp(pkgname);
if (unlikely(Grp.end()== true))
@@ -779,7 +779,7 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
}
std::string arch = "";
- if (pkgname.find(":") != string::npos)
+ if (pkgname.find(':') != string::npos)
arch = StringSplit(pkgname, ":")[1];
std::string i18n_pkgname = pkgname;
if (arch.size() != 0)
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index 139b10316..089bfd2ce 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -161,7 +161,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
// Attempt to fix busted symlink support for one instance
string OrigFile = File;
string::size_type Start = File.find("binary-");
- string::size_type End = File.find("/",Start+3);
+ string::size_type End = File.find('/',Start+3);
if (Start != string::npos && End != string::npos)
{
File.replace(Start,End-Start,"binary-all");