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-private/private-install.cc | 4 ++-- apt-private/private-source.cc | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'apt-private') diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index c619aa45a..33c529712 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -1114,8 +1114,8 @@ static bool AddIfVolatile(pkgSourceList *const SL, std::vector &Volat } else { - auto const found = pkg.name.rfind("/"); - if (found == pkg.name.find("/")) + auto const found = pkg.name.rfind('/'); + if (found == pkg.name.find('/')) _error->Error(_("Unsupported file %s given on commandline"), I); else { diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc index ebd3a980c..eb7eee931 100644 --- a/apt-private/private-source.cc +++ b/apt-private/private-source.cc @@ -86,21 +86,21 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name, TmpSrc = TmpSrc.substr(4); } // extract release - size_t found = TmpSrc.find_last_of("/"); + size_t found = TmpSrc.find_last_of('/'); if (found != std::string::npos) { RelTag = TmpSrc.substr(found+1); TmpSrc = TmpSrc.substr(0,found); } // extract the version - found = TmpSrc.find_last_of("="); + found = TmpSrc.find_last_of('='); if (found != std::string::npos) { VerTag = UserRequestedVerTag = TmpSrc.substr(found+1); TmpSrc = TmpSrc.substr(0,found); } // extract arch - found = TmpSrc.find_last_of(":"); + found = TmpSrc.find_last_of(':'); if (found != std::string::npos) { ArchTag = TmpSrc.substr(found+1); @@ -359,14 +359,14 @@ bool DoSource(CommandLine &CmdL) while (pos != std::string::npos) { pos += strlen("\nVcs-"); - std::string vcs = srec.substr(pos,srec.find(":",pos)-pos); + std::string vcs = srec.substr(pos,srec.find(':',pos)-pos); if(vcs == "Browser") { pos = srec.find("\nVcs-", pos); continue; } pos += vcs.length()+2; - std::string::size_type epos = srec.find("\n", pos); + std::string::size_type epos = srec.find('\n', pos); std::string const uri = srec.substr(pos,epos-pos); ioprintf(c1out, _("NOTICE: '%s' packaging is maintained in " "the '%s' version control system at:\n" @@ -806,7 +806,7 @@ bool DoBuildDep(CommandLine &CmdL) WriteBuildDependencyPackage(buildDepsPkgFile, pseudo, pseudoArch, GetBuildDeps(Last, Src.c_str(), hostArch)); std::string reltag = *I; - size_t found = reltag.find_last_of("/"); + size_t found = reltag.find_last_of('/'); if (found == std::string::npos) reltag.clear(); else -- cgit v1.2.3-70-g09d2