[lld] r358565 - [ELF] Use llvm::bsearch. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 01:00:46 PDT 2019


Author: maskray
Date: Wed Apr 17 01:00:46 2019
New Revision: 358565

URL: http://llvm.org/viewvc/llvm-project?rev=358565&view=rev
Log:
[ELF] Use llvm::bsearch. NFC

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

Modified:
    lld/trunk/ELF/DWARF.cpp
    lld/trunk/ELF/InputSection.cpp

Modified: lld/trunk/ELF/DWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DWARF.cpp?rev=358565&r1=358564&r2=358565&view=diff
==============================================================================
--- lld/trunk/ELF/DWARF.cpp (original)
+++ lld/trunk/ELF/DWARF.cpp Wed Apr 17 01:00:46 2019
@@ -81,9 +81,8 @@ template <class RelTy>
 Optional<RelocAddrEntry>
 LLDDwarfObj<ELFT>::findAux(const InputSectionBase &Sec, uint64_t Pos,
                            ArrayRef<RelTy> 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;

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=358565&r1=358564&r2=358565&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Apr 17 01:00:46 2019
@@ -1224,11 +1224,9 @@ SectionPiece *MergeInputSection::getSect
 
   // 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.




More information about the llvm-commits mailing list