From c6fcfbc98a70f40d3cef850b34f606091ee33d07 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 25 Jun 2015 17:51:07 +0000 Subject: [PATCH] COFF: Use std::equal to compare two lists of relocations. llvm-svn: 240665 --- lld/COFF/Chunks.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp index 74bbe6f..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(B1)) if (auto *C2 = dyn_cast(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. -- 2.7.4