[llvm] [ProfData] Improve efficiency of reader (PR #169730)
Snehasish Kumar via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 26 13:58:31 PST 2025
================
@@ -401,12 +401,27 @@ std::error_code ProfileSymbolList::read(const uint8_t *Data,
const char *ListStart = reinterpret_cast<const char *>(Data);
uint64_t Size = 0;
uint64_t StrNum = 0;
+ uint64_t ExpectedCount = 0;
+
+ // Scan forward to see how many elements we expect.
+ while (Size < ListSize) {
+ if (ListStart[Size] == '\0') ExpectedCount++;
+ Size++;
+ }
+
+ reserve(ExpectedCount);
----------------
snehasish wrote:
Should this be `reserve(std::min(ExpectedCount, ProfileSymbolListCutOff))`?
https://github.com/llvm/llvm-project/pull/169730
More information about the llvm-commits
mailing list