[PATCH] D55248: [ELF] Simplify getSectionPiece
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 4 13:54:45 PST 2018
MaskRay updated this revision to Diff 176709.
MaskRay added a comment.
Add llvm::
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55248/new/
https://reviews.llvm.org/D55248
Files:
ELF/InputSection.cpp
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -1223,18 +1223,12 @@
// 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.
- size_t Size = Pieces.size();
- size_t Idx = 0;
-
- while (Size != 1) {
- size_t H = Size / 2;
- Size -= H;
- if (Pieces[Idx + H].InputOff <= Offset)
- Idx += H;
- }
- if (Offset < Pieces[Idx].InputOff)
- --Idx;
- return &Pieces[Idx];
+ auto It2 =
+ llvm::upper_bound(Pieces, Offset, [](uint64_t Offset, SectionPiece P) {
+ return Offset < P.InputOff;
+ });
+ assert(Pieces[0].InputOff == 0 && It2 != Pieces.begin());
+ return &It2[-1];
}
// Returns the offset in an output section for a given input offset.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55248.176709.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181204/8188b17d/attachment.bin>
More information about the llvm-commits
mailing list