Skip to content

Commit 2bc3a19

Browse files
committed
[ELF] Use llvm::bsearch. NFC
Differential Revision: https://reviews.llvm.org/D60813 llvm-svn: 358565
1 parent c82e92b commit 2bc3a19

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lld/ELF/DWARF.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ template <class RelTy>
8181
Optional<RelocAddrEntry>
8282
LLDDwarfObj<ELFT>::findAux(const InputSectionBase &Sec, uint64_t Pos,
8383
ArrayRef<RelTy> Rels) const {
84-
auto It = std::lower_bound(
85-
Rels.begin(), Rels.end(), Pos,
86-
[](const RelTy &A, uint64_t B) { return A.r_offset < B; });
84+
auto It =
85+
llvm::bsearch(Rels, [=](const RelTy &A) { return Pos <= A.r_offset; });
8786
if (It == Rels.end() || It->r_offset != Pos)
8887
return None;
8988
const RelTy &Rel = *It;

lld/ELF/InputSection.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,9 @@ SectionPiece *MergeInputSection::getSectionPiece(uint64_t Offset) {
12241224

12251225
// If Offset is not at beginning of a section piece, it is not in the map.
12261226
// In that case we need to do a binary search of the original section piece vector.
1227-
auto It2 =
1228-
llvm::upper_bound(Pieces, Offset, [](uint64_t Offset, SectionPiece P) {
1229-
return Offset < P.InputOff;
1230-
});
1231-
return &It2[-1];
1227+
auto It = llvm::bsearch(Pieces,
1228+
[=](SectionPiece P) { return Offset < P.InputOff; });
1229+
return &It[-1];
12321230
}
12331231

12341232
// Returns the offset in an output section for a given input offset.

0 commit comments

Comments
 (0)