diff options
author | Rui Ueyama <ruiu@google.com> | 2015-06-25 17:51:07 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2015-06-25 17:51:07 +0000 |
commit | c6fcfbc98a70f40d3cef850b34f606091ee33d07 (patch) | |
tree | ee2af6b7253da7079331b99477b391cf474ad9c2 | |
parent | 6a7511bea952aff59756cc7407be608b4d179548 (diff) | |
download | llvm-c6fcfbc98a70f40d3cef850b34f606091ee33d07.zip llvm-c6fcfbc98a70f40d3cef850b34f606091ee33d07.tar.gz llvm-c6fcfbc98a70f40d3cef850b34f606091ee33d07.tar.bz2 |
COFF: Use std::equal to compare two lists of relocations.
llvm-svn: 240665
-rw-r--r-- | lld/COFF/Chunks.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp index 74bbe6fd..fde2407 100644 --- a/lld/COFF/Chunks.cpp +++ b/lld/COFF/Chunks.cpp @@ -186,24 +186,20 @@ bool SectionChunk::equals(const SectionChunk *X) const { return false; // Compare relocations - const coff_relocation *Rel1 = Relocs.begin(); - const coff_relocation *End = Relocs.end(); - const coff_relocation *Rel2 = X->Relocs.begin(); - for (; Rel1 != End; ++Rel1, ++Rel2) { - if (Rel1->Type != Rel2->Type) + auto Eq = [&](const coff_relocation &R1, const coff_relocation &R2) { + if (R1.Type != R2.Type) return false; - if (Rel1->VirtualAddress != Rel2->VirtualAddress) + if (R1.VirtualAddress != R2.VirtualAddress) return false; - SymbolBody *B1 = File->getSymbolBody(Rel1->SymbolTableIndex); - SymbolBody *B2 = X->File->getSymbolBody(Rel2->SymbolTableIndex); + SymbolBody *B1 = File->getSymbolBody(R1.SymbolTableIndex); + SymbolBody *B2 = X->File->getSymbolBody(R2.SymbolTableIndex); if (auto *C1 = dyn_cast<DefinedCOMDAT>(B1)) if (auto *C2 = dyn_cast<DefinedCOMDAT>(B2)) if (C1->getChunk() == C2->getChunk()) - continue; - if (B1 != B2) - return false; - } - return true; + return true; + return B1 == B2; + }; + return std::equal(Relocs.begin(), Relocs.end(), X->Relocs.begin(), Eq); } // Returns a pointer to this chunk or its replacement. |