From e677c7937e09e0cddb91df36a72af8facb24f859 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Mon, 30 Oct 2023 12:44:35 +0000 Subject: [PATCH] Recommend rtc::StringBuilder rather than + Bug: none Change-Id: Ib6d5d582b1c1c5032ba5c388e47963784db2b6b2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325282 Commit-Queue: Harald Alvestrand Reviewed-by: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#41039} --- g3doc/style-guide.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/g3doc/style-guide.md b/g3doc/style-guide.md index 71d1196df2..b32163f906 100644 --- a/g3doc/style-guide.md +++ b/g3doc/style-guide.md @@ -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.