From af5b9453a1908021cf75c348522c1a12eeb0dee4 Mon Sep 17 00:00:00 2001 From: Herman Semenoff Date: Wed, 8 Apr 2026 11:37:24 +0300 Subject: 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 --- apt-pkg/aptconfiguration.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg/aptconfiguration.cc') 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 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 ; color escaped. // | ; a simple color name // | ; a sequence of colors - if (color.find(" ") != color.npos) + if (color.find(' ') != color.npos) { std::string res; for (auto &&colorPart : VectorizeString(color, ' ')) -- cgit v1.2.3-70-g09d2