[llvm] [ProfData] Improve efficiency of reader (PR #169730)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 26 13:57:13 PST 2025


================
@@ -401,12 +401,26 @@ 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 (Offset < ListSize) {
----------------
snehasish wrote:

The `ExpectedCount` computation is correct since the underlying set only needs to hold N strings. The loop extracts individual strings from a char* block delimited by `'\0'`.

@mxms0 can you add a comment so explain this?

https://github.com/llvm/llvm-project/pull/169730


More information about the llvm-commits mailing list