[llvm] [Coverage] Speed up function record iteration (PR #122050)
Hana Dusíková via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 00:51:09 PST 2025
================
@@ -765,11 +779,29 @@ class FunctionRecordIterator
const FunctionRecord &operator*() const { return *Current; }
FunctionRecordIterator &operator++() {
- assert(Current != Records.end() && "incremented past end");
- ++Current;
+ advanceOne();
skipOtherFiles();
return *this;
}
+
+private:
+ void advanceOne() {
+ if (RecordIndices.empty()) {
+ // Iteration over all entries, advance in the list of records.
+ assert(Current != Records.end() && "incremented past end");
+ ++Current;
+ } else {
+ // Iterator over entries filtered by file name. Advance in the list of
+ // indices, and adjust the cursor in the list of records accordingly.
+ assert(CurrentIndex != RecordIndices.end() && "incremented past end");
+ ++CurrentIndex;
+ if (CurrentIndex == RecordIndices.end()) {
+ Current = Records.end();
+ } else {
+ Current = &Records[*CurrentIndex];
+ }
+ }
----------------
hanickadot wrote:
Does this maintain same order of iteration? There is a failing test. Maybe just fixing the test is enough.
https://github.com/llvm/llvm-project/pull/122050
More information about the llvm-commits
mailing list