| 1 |
.. title:: clang-tidy - performance-faster-string-find |
| 2 |
|
| 3 |
performance-faster-string-find |
| 4 |
============================== |
| 5 |
|
| 6 |
Optimize calls to ``std::string::find()`` and friends when the needle passed is |
| 7 |
a single character string literal. The character literal overload is more |
| 8 |
efficient. |
| 9 |
|
| 10 |
Examples: |
| 11 |
|
| 12 |
.. code-block:: c++ |
| 13 |
|
| 14 |
str.find("A"); |
| 15 |
|
| 16 |
// becomes |
| 17 |
|
| 18 |
str.find('A'); |
| 19 |
|
| 20 |
Options |
| 21 |
------- |
| 22 |
|
| 23 |
.. option:: StringLikeClasses |
| 24 |
|
| 25 |
Semicolon-separated list of names of string-like classes. By default only |
| 26 |
``::std::basic_string`` and ``::std::basic_string_view`` are considered. |
| 27 |
The check will only consider member functions named ``find``, ``rfind``, |
| 28 |
``find_first_of``, ``find_first_not_of``, ``find_last_of``, or |
| 29 |
``find_last_not_of`` within these classes. |