[PATCH] D89544: [CodingStandards] Clarify the recommendation to use SmallVector

Dmitri Gribenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 05:01:04 PDT 2020


gribozavr created this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
gribozavr requested review of this revision.

SmallVector is not unconditionally better than std::vector, it only
makes sense when the small size optimization is meaningful. In fact,
LLVM and Clang use std::vector a lot when the small size optimization is
not needed. Therefore, the wording "should usually be used" is
misleading.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89544

Files:
  llvm/docs/CodingStandards.rst


Index: llvm/docs/CodingStandards.rst
===================================================================
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -86,7 +86,8 @@
 there isn't a specific reason to favor the C++ implementation, it is generally
 preferable to use the LLVM library. For example, ``llvm::DenseMap`` should
 almost always be used instead of ``std::map`` or ``std::unordered_map``, and
-``llvm::SmallVector`` should usually be used instead of ``std::vector``.
+``llvm::SmallVector`` should be used instead of ``std::vector`` when the small
+size optimization makes sense.
 
 We explicitly avoid some standard facilities, like the I/O streams, and instead
 use LLVM's streams library (raw_ostream_). More detailed information on these


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89544.298598.patch
Type: text/x-patch
Size: 773 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201016/72af50dd/attachment.bin>


More information about the llvm-commits mailing list