Skip to content

Commit d551b1e

Browse files
mysterymathtstellar
authored andcommitted
[NFC] [llvm-cov] Remove unnecessary logic from llvm-cov debuginfod.
Indexed profiles already have a sorted and uniqued binary ID list, and due to this, duplicates are harmless in the list of binary IDs found, since it's set_differenced from the list in the indexed profile. Differential Revision: https://reviews.llvm.org/D136702 (cherry picked from commit 0a51eed)
1 parent 0b21322 commit d551b1e

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -410,30 +410,21 @@ CoverageMapping::load(ArrayRef<StringRef> ObjectFilenames,
410410
}
411411

412412
if (BIDFetcher) {
413-
const auto &CompareLT = [](object::BuildIDRef A, object::BuildIDRef B) {
414-
return StringRef(reinterpret_cast<const char *>(A.data()), A.size()) <
415-
StringRef(reinterpret_cast<const char *>(B.data()), B.size());
416-
};
417-
const auto &CompareEQ = [](object::BuildIDRef A, object::BuildIDRef B) {
418-
return StringRef(reinterpret_cast<const char *>(A.data()), A.size()) ==
419-
StringRef(reinterpret_cast<const char *>(B.data()), B.size());
420-
};
421413
std::vector<object::BuildID> ProfileBinaryIDs;
422414
if (Error E = ProfileReader->readBinaryIds(ProfileBinaryIDs))
423415
return createFileError(ProfileFilename, std::move(E));
424-
llvm::sort(ProfileBinaryIDs, CompareLT);
425-
ProfileBinaryIDs.erase(llvm::unique(ProfileBinaryIDs, CompareEQ),
426-
ProfileBinaryIDs.end());
427416

428417
SmallVector<object::BuildIDRef> BinaryIDsToFetch;
429418
if (!ProfileBinaryIDs.empty()) {
430-
llvm::sort(FoundBinaryIDs, CompareLT);
431-
FoundBinaryIDs.erase(llvm::unique(FoundBinaryIDs, CompareEQ),
432-
FoundBinaryIDs.end());
419+
const auto &Compare = [](object::BuildIDRef A, object::BuildIDRef B) {
420+
return std::lexicographical_compare(A.begin(), A.end(), B.begin(),
421+
B.end());
422+
};
423+
llvm::sort(FoundBinaryIDs, Compare);
433424
std::set_difference(
434425
ProfileBinaryIDs.begin(), ProfileBinaryIDs.end(),
435426
FoundBinaryIDs.begin(), FoundBinaryIDs.end(),
436-
std::inserter(BinaryIDsToFetch, BinaryIDsToFetch.end()), CompareLT);
427+
std::inserter(BinaryIDsToFetch, BinaryIDsToFetch.end()), Compare);
437428
}
438429

439430
for (object::BuildIDRef BinaryID : BinaryIDsToFetch) {

0 commit comments

Comments
 (0)