From 2bc3a19a49c780a8c557660b3e7013c9acab8250 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 17 Apr 2019 08:00:46 +0000 Subject: [PATCH] [ELF] Use llvm::bsearch. NFC Differential Revision: https://reviews.llvm.org/D60813 llvm-svn: 358565 --- lld/ELF/DWARF.cpp | 5 ++--- lld/ELF/InputSection.cpp | 8 +++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp index 2e0e677d7c7e..6b90a038e873 100644 --- a/lld/ELF/DWARF.cpp +++ b/lld/ELF/DWARF.cpp @@ -81,9 +81,8 @@ template Optional LLDDwarfObj::findAux(const InputSectionBase &Sec, uint64_t Pos, ArrayRef Rels) const { - auto It = std::lower_bound( - Rels.begin(), Rels.end(), Pos, - [](const RelTy &A, uint64_t B) { return A.r_offset < B; }); + auto It = + llvm::bsearch(Rels, [=](const RelTy &A) { return Pos <= A.r_offset; }); if (It == Rels.end() || It->r_offset != Pos) return None; const RelTy &Rel = *It; diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 58c3513aeff1..0ed3a70156f2 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -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. // In that case we need to do a binary search of the original section piece vector. - auto It2 = - llvm::upper_bound(Pieces, Offset, [](uint64_t Offset, SectionPiece P) { - return Offset < P.InputOff; - }); - return &It2[-1]; + auto It = llvm::bsearch(Pieces, + [=](SectionPiece P) { return Offset < P.InputOff; }); + return &It[-1]; } // Returns the offset in an output section for a given input offset. -- 2.34.1