[ELF] Use llvm::bsearch. NFC

Differential Revision: https://reviews.llvm.org/D60813

llvm-svn: 358565
This commit is contained in:
Fangrui Song 2019-04-17 08:00:46 +00:00
parent c82e92bca8
commit 2bc3a19a49
2 changed files with 5 additions and 8 deletions

View File

@ -81,9 +81,8 @@ template <class RelTy>
Optional<RelocAddrEntry> Optional<RelocAddrEntry>
LLDDwarfObj<ELFT>::findAux(const InputSectionBase &Sec, uint64_t Pos, LLDDwarfObj<ELFT>::findAux(const InputSectionBase &Sec, uint64_t Pos,
ArrayRef<RelTy> Rels) const { ArrayRef<RelTy> Rels) const {
auto It = std::lower_bound( auto It =
Rels.begin(), Rels.end(), Pos, llvm::bsearch(Rels, [=](const RelTy &A) { return Pos <= A.r_offset; });
[](const RelTy &A, uint64_t B) { return A.r_offset < B; });
if (It == Rels.end() || It->r_offset != Pos) if (It == Rels.end() || It->r_offset != Pos)
return None; return None;
const RelTy &Rel = *It; const RelTy &Rel = *It;

View File

@ -1224,11 +1224,9 @@ SectionPiece *MergeInputSection::getSectionPiece(uint64_t Offset) {
// If Offset is not at beginning of a section piece, it is not in the map. // If Offset is not at beginning of a section piece, it is not in the map.
// In that case we need to do a binary search of the original section piece vector. // In that case we need to do a binary search of the original section piece vector.
auto It2 = auto It = llvm::bsearch(Pieces,
llvm::upper_bound(Pieces, Offset, [](uint64_t Offset, SectionPiece P) { [=](SectionPiece P) { return Offset < P.InputOff; });
return Offset < P.InputOff; return &It[-1];
});
return &It2[-1];
} }
// Returns the offset in an output section for a given input offset. // Returns the offset in an output section for a given input offset.