diff options
author | Samuel Benzaquen <sbenza@google.com> | 2016-02-12 19:28:14 +0000 |
---|---|---|
committer | Samuel Benzaquen <sbenza@google.com> | 2016-02-12 19:28:14 +0000 |
commit | 51e1523d70842bd401b4a46940acf6d4ea19e483 (patch) | |
tree | 209928dcd0815c7fe56d9075cdc150282914b5d2 /clang-tools-extra/docs/clang-tidy | |
parent | 96fccc2d0912a39daba0cc0e3343987e8748133a (diff) | |
download | bcm5719-llvm-51e1523d70842bd401b4a46940acf6d4ea19e483.tar.gz bcm5719-llvm-51e1523d70842bd401b4a46940acf6d4ea19e483.zip |
[clang-tidy] Add check performance-faster-string-find
Summary:
Add check performance-faster-string-find.
It replaces single character string literals to character literals in calls to string::find and friends.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D16152
llvm-svn: 260712
Diffstat (limited to 'clang-tools-extra/docs/clang-tidy')
-rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/list.rst | 1 | ||||
-rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index fe1a0225e34..629dd603a69 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -80,6 +80,7 @@ Clang-Tidy Checks modernize-use-default modernize-use-nullptr modernize-use-override + performance-faster-string-find performance-for-range-copy performance-implicit-cast-in-loop readability-braces-around-statements diff --git a/clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst b/clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst new file mode 100644 index 00000000000..147f0c3815a --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst @@ -0,0 +1,22 @@ +.. title:: clang-tidy - performance-faster-string-find + +performance-faster-string-find +============================== + +Optimize calls to std::string::find() and friends when the needle passed is +a single character string literal. +The character literal overload is more efficient. + +By default only `std::basic_string` is considered. This list can be modified by +passing a `;` separated list of class names using the `StringLikeClasses` +option. The methods to consired are fixed, though. + +Examples: + +.. code-block:: c++ + + str.find("A"); + + // becomes + + str.find('A'); |