diff options
| author | Fangrui Song <maskray@google.com> | 2018-12-04 22:25:05 +0000 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2018-12-04 22:25:05 +0000 |
| commit | 01fbb06b12b0d12ed3fba7ab002c6daf53f2531c (patch) | |
| tree | 031f888654662912dd932c3bd74c9e6e50445ce6 | |
| parent | a9248fdfab95891e7978da1db84263c50bbc854d (diff) | |
| download | bcm5719-llvm-01fbb06b12b0d12ed3fba7ab002c6daf53f2531c.tar.gz bcm5719-llvm-01fbb06b12b0d12ed3fba7ab002c6daf53f2531c.zip | |
[ELF] Simplify getSectionPiece
Reviewers: ruiu, espindola
Reviewed By: ruiu
Subscribers: grimar, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D55248
llvm-svn: 348311
| -rw-r--r-- | lld/ELF/InputSection.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 38654d5a573..97df0331955 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -1223,18 +1223,11 @@ 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. - 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; + }); + return &It2[-1]; } // Returns the offset in an output section for a given input offset. |

