[PATCH] D13185: Scheduler / Regalloc: use unique_ptr[] instead of std::vector

escha via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 17:43:21 PDT 2015

> On Sep 25, 2015, at 5:32 PM, David Blaikie <dblaikie at gmail.com> wrote:
> On Fri, Sep 25, 2015 at 5:28 PM, escha via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> escha created this revision.
> escha added reviewers: MatzeB, arsenm, resistor.
> escha added a subscriber: llvm-commits.
> escha set the repository for this revision to rL LLVM.
> std::vector.resize() is actually about 2-3x slower than using unique_ptr, at least for me; it doesn't compile to bzero because the resize() in std:: consists of repeated appending (agh).
> Wait, what? Which standard library has that implementation? (is it necessary/implied by the standard, or just a poorly performing implementation that can/should be fixed?)

Unfortunately, like a lot of awful things in std::, it seems to be implied by the standard:

"If the current size is less than count,
1) additional default-inserted <http://en.cppreference.com/w/cpp/concept/DefaultInsertable> elements are appended
2) additional copies of value are appended”

The other option here is probably to use .reserve() and then .data(), and then bzero that (which gives the same results performance-wise), but that seems vastly uglier than just switching to a lighter-weight data structure.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150925/fb5fed50/attachment.html>

More information about the llvm-commits mailing list