aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2022-08-28 23:29:02 -0700
committerKazu Hirata <kazu@google.com>2022-08-28 23:29:02 -0700
commit20f0f15a4055d66fae494fc79bd76f14dee3954f (patch)
treef3936c440f56f75cea2c38866b47348a7962625e /clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
parent0e9d37ff95b5c574a8fde65bb176691e1a17d70d (diff)
downloadllvm-20f0f15a4055d66fae494fc79bd76f14dee3954f.zip
llvm-20f0f15a4055d66fae494fc79bd76f14dee3954f.tar.gz
llvm-20f0f15a4055d66fae494fc79bd76f14dee3954f.tar.bz2
Use StringRef::contains (NFC)
Diffstat (limited to 'clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
index 05ef855..cd221f2 100644
--- a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
@@ -68,9 +68,8 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) {
PtrToContainer = true;
}
const llvm::StringRef IneffContName = IneffCont->getName();
- const bool Unordered =
- IneffContName.find("unordered") != llvm::StringRef::npos;
- const bool Maplike = IneffContName.find("map") != llvm::StringRef::npos;
+ const bool Unordered = IneffContName.contains("unordered");
+ const bool Maplike = IneffContName.contains("map");
// Store if the key type of the container is compatible with the value
// that is searched for.
@@ -84,8 +83,7 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) {
const Expr *Arg = AlgCall->getArg(3);
const QualType AlgCmp =
Arg->getType().getUnqualifiedType().getCanonicalType();
- const unsigned CmpPosition =
- (IneffContName.find("map") == llvm::StringRef::npos) ? 1 : 2;
+ const unsigned CmpPosition = IneffContName.contains("map") ? 2 : 1;
const QualType ContainerCmp = IneffCont->getTemplateArgs()[CmpPosition]
.getAsType()
.getUnqualifiedType()