Recommend rtc::StringBuilder rather than +

Bug: none
Change-Id: Ib6d5d582b1c1c5032ba5c388e47963784db2b6b2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325282
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41039}
This commit is contained in:
Harald Alvestrand 2023-10-30 12:44:35 +00:00 committed by WebRTC LUCI CQ
parent 5ab1ab4eda
commit e677c7937e

View File

@ -127,6 +127,19 @@ For example,
See the [source code for `rtc::ArrayView`](api/array_view.h) for more detailed
docs.
### Strings
WebRTC uses std::string, with content assumed to be UTF-8. Note that this
has to be verified whenever accepting external input.
For concatenation of strings, use rtc::SimpleStringBuilder.
The following string building tools are NOT recommended:
* The + operator. See https://abseil.io/tips/3 for why not.
* absl::StrCat, absl::StrAppend, absl::StrJoin. These are optimized for
speed, not code size, and have significant code size overhead.
* strcat. It is too easy to create buffer overflows.
### sigslot
SIGSLOT IS DEPRECATED.