[lld] r285811 - Don't use getNumSections.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 07:42:20 PDT 2016


Author: rafael
Date: Wed Nov  2 09:42:20 2016
New Revision: 285811

URL: http://llvm.org/viewvc/llvm-project?rev=285811&view=rev
Log:
Don't use getNumSections.

It is just the size of sections() which we were already calling.

Modified:
    lld/trunk/ELF/InputFiles.cpp

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=285811&r1=285810&r2=285811&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Wed Nov  2 09:42:20 2016
@@ -286,12 +286,13 @@ bool elf::ObjectFile<ELFT>::shouldMerge(
 template <class ELFT>
 void elf::ObjectFile<ELFT>::initializeSections(
     DenseSet<CachedHashStringRef> &ComdatGroups) {
-  uint64_t Size = this->ELFObj.getNumSections();
+  const ELFFile<ELFT> &Obj = this->ELFObj;
+  ArrayRef<Elf_Shdr> ObjSections = check(Obj.sections());
+  uint64_t Size = ObjSections.size();
   Sections.resize(Size);
   unsigned I = -1;
-  const ELFFile<ELFT> &Obj = this->ELFObj;
   StringRef SectionStringTable = check(Obj.getSectionStringTable());
-  for (const Elf_Shdr &Sec : check(Obj.sections())) {
+  for (const Elf_Shdr &Sec : ObjSections) {
     ++I;
     if (Sections[I] == &InputSection<ELFT>::Discarded)
       continue;




More information about the llvm-commits mailing list