1.. title:: clang-tidy - abseil-faster-strsplit-delimiter 2 3abseil-faster-strsplit-delimiter 4================================ 5 6Finds instances of ``absl::StrSplit()`` or ``absl::MaxSplits()`` where the 7delimiter is a single character string literal and replaces with a character. 8The check will offer a suggestion to change the string literal into a character. 9It will also catch code using ``absl::ByAnyChar()`` for just a single character 10and will transform that into a single character as well. 11 12These changes will give the same result, but using characters rather than 13single character string literals is more efficient and readable. 14 15Examples: 16 17.. code-block:: c++ 18 19 // Original - the argument is a string literal. 20 for (auto piece : absl::StrSplit(str, "B")) { 21 22 // Suggested - the argument is a character, which causes the more efficient 23 // overload of absl::StrSplit() to be used. 24 for (auto piece : absl::StrSplit(str, 'B')) { 25 26 27 // Original - the argument is a string literal inside absl::ByAnyChar call. 28 for (auto piece : absl::StrSplit(str, absl::ByAnyChar("B"))) { 29 30 // Suggested - the argument is a character, which causes the more efficient 31 // overload of absl::StrSplit() to be used and we do not need absl::ByAnyChar 32 // anymore. 33 for (auto piece : absl::StrSplit(str, 'B')) { 34 35 36 // Original - the argument is a string literal inside absl::MaxSplits call. 37 for (auto piece : absl::StrSplit(str, absl::MaxSplits("B", 1))) { 38 39 // Suggested - the argument is a character, which causes the more efficient 40 // overload of absl::StrSplit() to be used. 41 for (auto piece : absl::StrSplit(str, absl::MaxSplits('B', 1))) { 42