Skip to content

Commit f5ef9bd

Browse files
[memprof] Call SmallVector::reserve (#86055)
With one raw memprof file I have, NumPCs averages about 41. Given the default number of inline elements being 8 for SmallVector<uint64_t>, we should reserve the storage in advance.
1 parent 796efa8 commit f5ef9bd

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llvm/lib/ProfileData/RawMemProfReader.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ CallStackMap readStackInfo(const char *Ptr) {
127127
endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
128128

129129
SmallVector<uint64_t> CallStack;
130+
CallStack.reserve(NumPCs);
130131
for (uint64_t J = 0; J < NumPCs; J++) {
131132
CallStack.push_back(
132133
endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr));

0 commit comments

Comments
 (0)