COFF: Simplify. NFC.

llvm-svn: 240666
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index fde2407..2acc722 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -59,9 +59,8 @@
   if (!hasData())
     return;
   // Copy section contents from source object file to output file.
-  ArrayRef<uint8_t> Data;
-  File->getCOFFObj()->getSectionContents(Header, Data);
-  memcpy(Buf + FileOff, Data.data(), Data.size());
+  ArrayRef<uint8_t> A = getContents();
+  memcpy(Buf + FileOff, A.data(), A.size());
 
   // Apply relocations.
   for (const coff_relocation &Rel : Relocs) {
@@ -155,8 +154,7 @@
 }
 
 uint64_t SectionChunk::getHash() const {
-  ArrayRef<uint8_t> A;
-  File->getCOFFObj()->getSectionContents(Header, A);
+  ArrayRef<uint8_t> A = getContents();
   return hash_combine(getPermissions(),
                       llvm::hash_value(SectionName),
                       NumRelocs,
@@ -178,11 +176,7 @@
     return false;
 
   // Compare data
-  ArrayRef<uint8_t> A, B;
-  File->getCOFFObj()->getSectionContents(Header, A);
-  X->File->getCOFFObj()->getSectionContents(X->Header, B);
-  assert(A.size() == B.size());
-  if (memcmp(A.data(), B.data(), A.size()))
+  if (getContents() != X->getContents())
     return false;
 
   // Compare relocations
@@ -202,6 +196,12 @@
   return std::equal(Relocs.begin(), Relocs.end(), X->Relocs.begin(), Eq);
 }
 
+ArrayRef<uint8_t> SectionChunk::getContents() const {
+  ArrayRef<uint8_t> A;
+  File->getCOFFObj()->getSectionContents(Header, A);
+  return A;
+}
+
 // Returns a pointer to this chunk or its replacement.
 SectionChunk *SectionChunk::repl() {
   while (Ptr != Ptr->Ptr)