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

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 26 13:17:45 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) {
----------------
vitalybuka wrote:

It would be cleaner to have exactly the same condition

```
while (Size < ListSize && StrNum < ProfileSymbolListCutOff) {
  Offset++;
}
```

As is, I am not sure understand why 
Only  `ListStart[Offset] == '\0'` needs a reserve?

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


More information about the llvm-commits mailing list