[PATCH] D60792: Time profiler: optimize json output time
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 16 13:12:59 PDT 2019
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.
LG, thank you.
================
Comment at: llvm/lib/Support/TimeProfiler.cpp:92
json::Array Events;
+ Events.reserve(Entries.size() + CountAndTotalPerName.size() + 1);
----------------
Just do
```
const size_t ExpectedEntryCount = Entries.size() + CountAndTotalPerName.size() + 1;
Events.reserve(ExpectedEntryCount);
...
assert(Events.size() == ExpectedEntryCount && "Size prediction failed");
```
else they //could// drift apart.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60792/new/
https://reviews.llvm.org/D60792
More information about the llvm-commits
mailing list