From 80569ea2be144d9ac7088a7bef178c3a679f05e3 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Mon, 17 Jan 2022 16:11:02 +0100 Subject: [PATCH] Refresh WebRTC style guide Remove advice to keep legacy style for consistency because it condridicts a recent addition to style guide goals Remove debatable reason for banning std::shared_ptr, keep main reason to ban it as the only one. Bug: None Change-Id: I4c31f9247a33430df0b286a15f1a35ab23060d1c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247183 Reviewed-by: Artem Titov Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#35720} --- g3doc/style-guide.md | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/g3doc/style-guide.md b/g3doc/style-guide.md index 63ca7d9a5c..5a2487ce15 100644 --- a/g3doc/style-guide.md +++ b/g3doc/style-guide.md @@ -1,16 +1,12 @@ # WebRTC coding style guide - + ## General advice Some older parts of the code violate the style guide in various ways. - -* If making small changes to such code, follow the style guide when it's - reasonable to do so, but in matters of formatting etc., it is often better to - be consistent with the surrounding code. -* If making large changes to such code, consider first cleaning it up in a +If making large changes to such code, consider first cleaning it up in a separate CL. ## C++ @@ -141,9 +137,7 @@ The following smart pointer types are recommended: * `rtc::scoped_refptr` for all objects with shared ownership Use of `std::shared_ptr` is *not permitted*. It is banned in the Chromium style -guide (overriding the Google style guide), and offers no compelling advantage -over `rtc::scoped_refptr` (which is cloned from the corresponding Chromium -type). See the +guide (overriding the Google style guide). See the [list of banned C++ library features in Chromium][chr-std-shared-ptr] for more information. @@ -152,7 +146,7 @@ In most cases, one will want to explicitly control lifetimes, and therefore use exist both from the API users and internally, with no way to invalidate pointers held by the API user, `rtc::scoped_refptr` can be appropriate. -[chr-std-shared-ptr]: https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++11.md#shared-pointers +[chr-std-shared-ptr]: https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++11.md#shared-pointers-banned ### `std::bind` @@ -180,11 +174,8 @@ headers you need. There's a substantial chunk of legacy C code in WebRTC, and a lot of it is old enough that it violates the parts of the C++ style guide that also applies to C (naming etc.) for the simple reason that it pre-dates the use of the current C++ -style guide for this code base. - -* If making small changes to C code, mimic the style of the surrounding code. -* If making large changes to C code, consider converting the whole thing to C++ - first. +style guide for this code base. If making large changes to C code, consider +converting the whole thing to C++ first. ## Java