Skip to content

Commit

Permalink
[memprof] Call SmallVector::reserve (#86055)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kazutakahirata committed Mar 21, 2024
1 parent 796efa8 commit f5ef9bd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions llvm/lib/ProfileData/RawMemProfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ CallStackMap readStackInfo(const char *Ptr) {
endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);

SmallVector<uint64_t> CallStack;
CallStack.reserve(NumPCs);
for (uint64_t J = 0; J < NumPCs; J++) {
CallStack.push_back(
endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr));
Expand Down

0 comments on commit f5ef9bd

Please sign in to comment.