| 1 |
.. title:: clang-tidy - abseil-redundant-strcat-calls |
| 2 |
|
| 3 |
abseil-redundant-strcat-calls |
| 4 |
============================= |
| 5 |
|
| 6 |
Suggests removal of unnecessary calls to ``absl::StrCat`` when the result is |
| 7 |
being passed to another call to ``absl::StrCat`` or ``absl::StrAppend``. |
| 8 |
|
| 9 |
The extra calls cause unnecessary temporary strings to be constructed. Removing |
| 10 |
them makes the code smaller and faster. |
| 11 |
|
| 12 |
Examples: |
| 13 |
|
| 14 |
.. code-block:: c++ |
| 15 |
|
| 16 |
std::string s = absl::StrCat("A", absl::StrCat("B", absl::StrCat("C", "D"))); |
| 17 |
//before |
| 18 |
|
| 19 |
std::string s = absl::StrCat("A", "B", "C", "D"); |
| 20 |
//after |
| 21 |
|
| 22 |
absl::StrAppend(&s, absl::StrCat("E", "F", "G")); |
| 23 |
//before |
| 24 |
|
| 25 |
absl::StrAppend(&s, "E", "F", "G"); |
| 26 |
//after |