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}
diff --git a/g3doc/style-guide.md b/g3doc/style-guide.md index 71d1196..b32163f 100644 --- a/g3doc/style-guide.md +++ b/g3doc/style-guide.md
@@ -127,6 +127,19 @@ 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.