Previously, SimpleReferences has two pointers to previous and next references,
making them elements of linked lists. I don't know how this design choice was
made, but it looks like we can just use plain std::vector instead of std::ilist.
Performance-wise this patch is neutral.
Details
- Reviewers
- None
Diff Detail
Event Timeline
SimpleReference was implemented using a vector not so long ago, but that design choice was made because std::vector is not bumpPtrAllocator friendly.
Mach-O implementation (at least) uses a bumpPtrAllocator to allocate the SimpleReferences. So SimpleReference destructor is never call, and so are members destructor.
If you use a std::vector, it means you will leak the vector storage memory. As all ilist nodes are allocated using the bumpPtr allocator, we don’t have that issue.
I think SmallVector guarantees the array it contains is contiguous in
memory. That data structure does not work well with BumpPtrAllocator
because garbage after extending the array is not reclaimed until the whole
buffer is discarded. That makes memory consumption of a small vector from
O(n) to O(n^2).
That being said, that behavior might be acceptable if we rarely extend
SmallVectors. So, maybe it's not a bad idea, but I don't know if it's good
enough to add an additional parameter to SmallVector's constructor.