xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/abseil/redundant-strcat-calls.rst (revision 6e566bc5523f743bc34a7e26f050f1f2b4d699a8)
1.. title:: clang-tidy - abseil-redundant-strcat-calls
2
3abseil-redundant-strcat-calls
4=============================
5
6Suggests removal of unnecessary calls to ``absl::StrCat`` when the result is
7being passed to another call to ``absl::StrCat`` or ``absl::StrAppend``.
8
9The extra calls cause unnecessary temporary strings to be constructed. Removing
10them makes the code smaller and faster.
11
12Examples:
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
27