@@ -587,31 +587,27 @@ Error RawMemProfReader::symbolizeAndFilterStackFrames(
587
587
std::vector<std::string>
588
588
RawMemProfReader::peekBuildIds (MemoryBuffer *DataBuffer) {
589
589
const char *Next = DataBuffer->getBufferStart ();
590
- // Use a set + vector since a profile file may contain multiple raw profile
590
+ // Use a SetVector since a profile file may contain multiple raw profile
591
591
// dumps, each with segment information. We want them unique and in order they
592
592
// were stored in the profile; the profiled binary should be the first entry.
593
593
// The runtime uses dl_iterate_phdr and the "... first object visited by
594
594
// callback is the main program."
595
595
// https://man7.org/linux/man-pages/man3/dl_iterate_phdr.3.html
596
- std::vector<std::string> BuildIds;
597
- llvm::SmallSet<std::string, 10 > BuildIdsSet;
596
+ llvm::SetVector<std::string, std::vector<std::string>,
597
+ llvm::SmallSet<std::string, 10 >>
598
+ BuildIds;
598
599
while (Next < DataBuffer->getBufferEnd ()) {
599
600
auto *Header = reinterpret_cast <const memprof::Header *>(Next);
600
601
601
602
const llvm::SmallVector<SegmentEntry> Entries =
602
603
readSegmentEntries (Next + Header->SegmentOffset );
603
604
604
- for (const auto &Entry : Entries) {
605
- const std::string Id = getBuildIdString (Entry);
606
- if (BuildIdsSet.contains (Id))
607
- continue ;
608
- BuildIds.push_back (Id);
609
- BuildIdsSet.insert (Id);
610
- }
605
+ for (const auto &Entry : Entries)
606
+ BuildIds.insert (getBuildIdString (Entry));
611
607
612
608
Next += Header->TotalSize ;
613
609
}
614
- return BuildIds;
610
+ return BuildIds. takeVector () ;
615
611
}
616
612
617
613
Error RawMemProfReader::readRawProfile (
0 commit comments