[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:24:38 PDT 2020


gribozavr2 added reviewers: jdoerfert, rjmccall.
gribozavr2 added a comment.

In D89544#2334494 <https://reviews.llvm.org/D89544#2334494>, @lebedev.ri wrote:

> What reasoning was used in the patch that added that wording?

https://reviews.llvm.org/D74340

> IIRC `llvm::SmallVector` is better than `std::vector` also because
> former doubles the allocation size instead of just increasing it.

`std::vector` must also use a multiplicative strategy in order to provide O(1) `push_back`. The C++ standard does not guarantee the specific factor though.

As written, the wording can be read to suggest to use `llvm::SmallVector<T, 0>` instead of `std::vector<T>`. Is that the intent?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89544/new/

https://reviews.llvm.org/D89544



More information about the llvm-commits mailing list