Use basic_string::find(char) instead of basic_string::find(const char *s, size_type pos=0)
Many (StringRef) cannot be detected by clang-tidy performance-faster-string-find.
This commit is contained in:
parent
a906e3eccd
commit
c70f36865e
|
@ -176,7 +176,7 @@ void MakeSmartPtrCheck::checkConstruct(SourceManager &SM, ASTContext *Ctx,
|
|||
}
|
||||
|
||||
// Find the location of the template's left angle.
|
||||
size_t LAngle = ExprStr.find("<");
|
||||
size_t LAngle = ExprStr.find('<');
|
||||
SourceLocation ConstructCallEnd;
|
||||
if (LAngle == StringRef::npos) {
|
||||
// If the template argument is missing (because it is part of the alias)
|
||||
|
|
|
@ -75,7 +75,7 @@ static bool isPlatformEnvironment(const TargetInfo &Target, StringRef Feature) {
|
|||
return true;
|
||||
|
||||
auto CmpPlatformEnv = [](StringRef LHS, StringRef RHS) {
|
||||
auto Pos = LHS.find("-");
|
||||
auto Pos = LHS.find('-');
|
||||
if (Pos == StringRef::npos)
|
||||
return false;
|
||||
SmallString<128> NewLHS = LHS.slice(0, Pos);
|
||||
|
|
|
@ -2603,7 +2603,7 @@ static std::string qualifyWindowsLibrary(llvm::StringRef Lib) {
|
|||
// If the argument does not end in .lib, automatically add the suffix.
|
||||
// If the argument contains a space, enclose it in quotes.
|
||||
// This matches the behavior of MSVC.
|
||||
bool Quote = (Lib.find(" ") != StringRef::npos);
|
||||
bool Quote = (Lib.find(' ') != StringRef::npos);
|
||||
std::string ArgStr = Quote ? "\"" : "";
|
||||
ArgStr += Lib;
|
||||
if (!Lib.endswith_lower(".lib") && !Lib.endswith_lower(".a"))
|
||||
|
|
|
@ -157,7 +157,7 @@ parseCrossTUIndex(StringRef IndexPath) {
|
|||
unsigned LineNo = 1;
|
||||
while (std::getline(ExternalMapFile, Line)) {
|
||||
StringRef LineRef{Line};
|
||||
const size_t Delimiter = LineRef.find(" ");
|
||||
const size_t Delimiter = LineRef.find(' ');
|
||||
if (Delimiter > 0 && Delimiter != std::string::npos) {
|
||||
StringRef LookupName = LineRef.substr(0, Delimiter);
|
||||
|
||||
|
|
|
@ -382,7 +382,7 @@ public:
|
|||
StringRef Mods = getNextModifiers(Proto, Pos);
|
||||
while (!Mods.empty()) {
|
||||
Types.emplace_back(InTS, Mods);
|
||||
if (Mods.find("!") != StringRef::npos)
|
||||
if (Mods.find('!') != StringRef::npos)
|
||||
PolymorphicKeyType = Types.size() - 1;
|
||||
|
||||
Mods = getNextModifiers(Proto, Pos);
|
||||
|
|
|
@ -207,7 +207,7 @@ public:
|
|||
/// a short form without the type-specifiers, e.g. 'svld1(..)' instead of
|
||||
/// 'svld1_u32(..)'.
|
||||
static bool isOverloadedIntrinsic(StringRef Name) {
|
||||
auto BrOpen = Name.find("[");
|
||||
auto BrOpen = Name.find('[');
|
||||
auto BrClose = Name.find(']');
|
||||
return BrOpen != std::string::npos && BrClose != std::string::npos;
|
||||
}
|
||||
|
@ -893,14 +893,14 @@ std::string Intrinsic::mangleName(ClassKind LocalCK) const {
|
|||
|
||||
if (LocalCK == ClassG) {
|
||||
// Remove the square brackets and everything in between.
|
||||
while (S.find("[") != std::string::npos) {
|
||||
auto Start = S.find("[");
|
||||
while (S.find('[') != std::string::npos) {
|
||||
auto Start = S.find('[');
|
||||
auto End = S.find(']');
|
||||
S.erase(Start, (End-Start)+1);
|
||||
}
|
||||
} else {
|
||||
// Remove the square brackets.
|
||||
while (S.find("[") != std::string::npos) {
|
||||
while (S.find('[') != std::string::npos) {
|
||||
auto BrPos = S.find('[');
|
||||
if (BrPos != std::string::npos)
|
||||
S.erase(BrPos, 1);
|
||||
|
|
|
@ -666,7 +666,7 @@ private:
|
|||
// regex {search-regex}
|
||||
|
||||
// Parse action.
|
||||
auto action_end_pos = rule_text.find(" ");
|
||||
auto action_end_pos = rule_text.find(' ');
|
||||
if (action_end_pos == std::string::npos) {
|
||||
error.SetErrorStringWithFormat("could not parse filter rule "
|
||||
"action from \"%s\"",
|
||||
|
|
|
@ -108,7 +108,7 @@ rescheduleLexographically(std::vector<MachineInstr *> instructions,
|
|||
OS.flush();
|
||||
|
||||
// Trim the assignment, or start from the beginning in the case of a store.
|
||||
const size_t i = S.find("=");
|
||||
const size_t i = S.find('=');
|
||||
StringInstrMap.push_back({(i == std::string::npos) ? S : S.substr(i), II});
|
||||
}
|
||||
|
||||
|
|
|
@ -1004,7 +1004,7 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix,
|
|||
|
||||
// Parse string variable or legacy @LINE expression.
|
||||
if (!IsNumBlock) {
|
||||
size_t VarEndIdx = MatchStr.find(":");
|
||||
size_t VarEndIdx = MatchStr.find(':');
|
||||
size_t SpacePos = MatchStr.substr(0, VarEndIdx).find_first_of(" \t");
|
||||
if (SpacePos != StringRef::npos) {
|
||||
SM.PrintMessage(SMLoc::getFromPointer(MatchStr.data() + SpacePos),
|
||||
|
|
|
@ -324,7 +324,7 @@ StringRef sys::detail::getHostCPUNameForS390x(StringRef ProcCpuinfoContent) {
|
|||
SmallVector<StringRef, 32> CPUFeatures;
|
||||
for (unsigned I = 0, E = Lines.size(); I != E; ++I)
|
||||
if (Lines[I].startswith("features")) {
|
||||
size_t Pos = Lines[I].find(":");
|
||||
size_t Pos = Lines[I].find(':');
|
||||
if (Pos != StringRef::npos) {
|
||||
Lines[I].drop_front(Pos + 1).split(CPUFeatures, ' ');
|
||||
break;
|
||||
|
|
|
@ -179,7 +179,7 @@ void SystemZHazardRecognizer::dumpSU(SUnit *SU, raw_ostream &OS) const {
|
|||
*SchedModel->getProcResource(PI->ProcResourceIdx);
|
||||
std::string FU(PRD.Name);
|
||||
// trim e.g. Z13_FXaUnit -> FXa
|
||||
FU = FU.substr(FU.find("_") + 1);
|
||||
FU = FU.substr(FU.find('_') + 1);
|
||||
size_t Pos = FU.find("Unit");
|
||||
if (Pos != std::string::npos)
|
||||
FU.resize(Pos);
|
||||
|
|
|
@ -691,7 +691,7 @@ static const void *getSymbolsAndView(claimed_file &F) {
|
|||
static void getThinLTOOldAndNewSuffix(std::string &OldSuffix,
|
||||
std::string &NewSuffix) {
|
||||
assert(options::thinlto_object_suffix_replace.empty() ||
|
||||
options::thinlto_object_suffix_replace.find(";") != StringRef::npos);
|
||||
options::thinlto_object_suffix_replace.find(';') != StringRef::npos);
|
||||
StringRef SuffixReplace = options::thinlto_object_suffix_replace;
|
||||
auto Split = SuffixReplace.split(';');
|
||||
OldSuffix = std::string(Split.first);
|
||||
|
@ -847,7 +847,7 @@ static CodeGenOpt::Level getCGOptLevel() {
|
|||
static void getThinLTOOldAndNewPrefix(std::string &OldPrefix,
|
||||
std::string &NewPrefix) {
|
||||
StringRef PrefixReplace = options::thinlto_prefix_replace;
|
||||
assert(PrefixReplace.empty() || PrefixReplace.find(";") != StringRef::npos);
|
||||
assert(PrefixReplace.empty() || PrefixReplace.find(';') != StringRef::npos);
|
||||
auto Split = PrefixReplace.split(';');
|
||||
OldPrefix = std::string(Split.first);
|
||||
NewPrefix = std::string(Split.second);
|
||||
|
|
|
@ -465,7 +465,7 @@ static void createCombinedModuleSummaryIndex() {
|
|||
static void getThinLTOOldAndNewPrefix(std::string &OldPrefix,
|
||||
std::string &NewPrefix) {
|
||||
assert(ThinLTOPrefixReplace.empty() ||
|
||||
ThinLTOPrefixReplace.find(";") != StringRef::npos);
|
||||
ThinLTOPrefixReplace.find(';') != StringRef::npos);
|
||||
StringRef PrefixReplace = ThinLTOPrefixReplace;
|
||||
std::pair<StringRef, StringRef> Split = PrefixReplace.split(";");
|
||||
OldPrefix = Split.first.str();
|
||||
|
|
Loading…
Reference in New Issue