[PATCH] D91467: ADT: Take small enough, trivially copyable T by value in SmallVector

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 13 15:34:18 PST 2020


dexonsmith created this revision.
Herald added a subscriber: ributzka.
Herald added a project: LLVM.
dexonsmith requested review of this revision.

This changes functions like `SmallVector::push_back()` to take their `T`
parameter by-value instead of `const T&` when `T` is trivially copyable
and "small enough" (16B or smaller, but this is easy to tune). When this
takes effect, the changed functions no longer have iterator invalidation
gotchas.

This conditionally disables `SmallVectorImpl::insert(iterator, T&&)` by
taking the `iterator` as a template argument to allow the use of
`std::enable_if`.


https://reviews.llvm.org/D91467

Files:
  llvm/include/llvm/ADT/SmallVector.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91467.305278.patch
Type: text/x-patch
Size: 4553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201113/2652efe2/attachment.bin>


More information about the llvm-commits mailing list