[PATCH] D94739: ADT: Fix reference invalidation in SmallVector::emplace_back and the size+value version of SmallVector::assign
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 15 09:34:11 PST 2021
dexonsmith updated this revision to Diff 316987.
dexonsmith added a comment.
Simplified `emplace_back` and addressed the concern I had with copying large POD-like types too often.
- Moved it back to `SmallVectorImpl`, only delegating to `SmallVectorTemplateBase` for `growAndEmplaceBack()`.
- Now it only defers to `push_back` when growing (still just for POD-like types).
- Also improved the comment to explain why the copy makes sense even for large POD-like types: that it's better than losing the `realloc` optimization.
See also https://reviews.llvm.org/D94800, which potentially speeds up `push_back` in a minor way for small POD-like types.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94739/new/
https://reviews.llvm.org/D94739
Files:
llvm/include/llvm/ADT/SmallVector.h
llvm/lib/Support/SmallVector.cpp
llvm/unittests/ADT/SmallVectorTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94739.316987.patch
Type: text/x-patch
Size: 17480 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210115/15de7aeb/attachment.bin>
More information about the llvm-commits
mailing list