summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2016-03-18 20:14:35 +0000
committerSamuel Benzaquen <sbenza@google.com>2016-03-18 20:14:35 +0000
commitd7f2e34e040d048c4741586d90f42f0919f09344 (patch)
tree92152da6c971086b5043f641f47d14f2e7896bf3 /clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
parent024f4c17d15ae87c5d453c2f65dfccdbfe410908 (diff)
downloadbcm5719-llvm-d7f2e34e040d048c4741586d90f42f0919f09344.tar.gz
bcm5719-llvm-d7f2e34e040d048c4741586d90f42f0919f09344.zip
[clang-tidy] Use hasAnyName() instead of matchesName().
matchesName() uses regular expressions and it is very slow. hasAnyName() gives the same result and it is much faster. A benchmark (with all the checks enabled) shows a ~5% speed up of clang-tidy. llvm-svn: 263822
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
index 94e3785994c..d585590128f 100644
--- a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
@@ -33,13 +33,16 @@ void InefficientAlgorithmCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
- const std::string Algorithms =
- "^::std::(find|count|equal_range|lower_bound|upper_bound)$";
- const auto ContainerMatcher = classTemplateSpecializationDecl(
- matchesName("^::std::(unordered_)?(multi)?(set|map)$"));
+ const auto Algorithms =
+ hasAnyName("::std::find", "::std::count", "::std::equal_range",
+ "::std::lower_bound", "::std::upper_bound");
+ const auto ContainerMatcher = classTemplateSpecializationDecl(hasAnyName(
+ "::std::set", "::std::map", "::std::multiset", "::std::multimap",
+ "::std::unordered_set", "::std::unordered_map"));
+
const auto Matcher =
callExpr(
- callee(functionDecl(matchesName(Algorithms))),
+ callee(functionDecl(Algorithms)),
hasArgument(
0, cxxConstructExpr(has(cxxMemberCallExpr(
callee(cxxMethodDecl(hasName("begin"))),
OpenPOWER on IntegriCloud