From 7b1e94f7a87c006b5420ed8491c0bc47373d9fad Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Sun, 20 Nov 2022 00:20:28 +0000 Subject: [PATCH] doc: Update coding-style.rst with clang-tidy readability-container-size-empty check --- doc/contributing/source/coding-style.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/contributing/source/coding-style.rst b/doc/contributing/source/coding-style.rst index 9663b6bdc..4c891e5a3 100644 --- a/doc/contributing/source/coding-style.rst +++ b/doc/contributing/source/coding-style.rst @@ -1299,6 +1299,10 @@ of rules that should be observed while developing code. myVector.emplace_back(2); myVector.emplace_back(3); +- Prefer to use the ``empty()`` function of STL containers (e.g., ``std::vector``), + instead of the condition ``size() > 0``, to avoid unnecessarily calculating the + size of the container. + - Avoid unnecessary calls to the functions ``.c_str()`` and ``.data()`` of ``std::string``.