[lld] r206022 - [ELF] Remove redundant conversion of section content from ArrayRef to

Simon Atanasyan simon at atanasyan.com
Fri Apr 11 00:25:29 PDT 2014


Author: atanasyan
Date: Fri Apr 11 02:25:29 2014
New Revision: 206022

URL: http://llvm.org/viewvc/llvm-project?rev=206022&view=rev
Log:
[ELF] Remove redundant conversion of section content from ArrayRef to
StringRef before calling the createSectionAtom() method and reverse
conversion inside the method.

No functional changes.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.h

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=206022&r1=206021&r2=206022&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Fri Apr 11 02:25:29 2014
@@ -201,7 +201,7 @@ protected:
   /// section that have no symbols.
   virtual ELFDefinedAtom<ELFT> *createSectionAtom(const Elf_Shdr *section,
                                                   StringRef sectionName,
-                                                  StringRef sectionContents);
+                                                  ArrayRef<uint8_t> contents);
 
   /// Return the default reloc addend for references.
   virtual int64_t defaultRelocAddend(const Reference &) const;
@@ -621,12 +621,9 @@ template <class ELFT> error_code ELFFile
     if (error_code ec = sectionContents.getError())
       return ec;
 
-    StringRef secCont(reinterpret_cast<const char *>(sectionContents->begin()),
-                      sectionContents->size());
-
     if (handleSectionWithNoSymbols(section, symbols)) {
       ELFDefinedAtom<ELFT> *newAtom =
-          createSectionAtom(section, *sectionName, secCont);
+          createSectionAtom(section, *sectionName, *sectionContents);
       _definedAtoms._atoms.push_back(newAtom);
       newAtom->setOrdinal(++_ordinal);
       continue;
@@ -879,7 +876,7 @@ bool ELFFile<ELFT>::isMergeableStringSec
 template <class ELFT>
 ELFDefinedAtom<ELFT> *
 ELFFile<ELFT>::createSectionAtom(const Elf_Shdr *section, StringRef sectionName,
-                                 StringRef sectionContents) {
+                                 ArrayRef<uint8_t> content) {
   Elf_Sym *sym = new (_readerStorage) Elf_Sym;
   sym->st_name = 0;
   sym->setBindingAndType(llvm::ELF::STB_LOCAL, llvm::ELF::STT_SECTION);
@@ -887,8 +884,6 @@ ELFFile<ELFT>::createSectionAtom(const E
   sym->st_shndx = 0;
   sym->st_value = 0;
   sym->st_size = 0;
-  ArrayRef<uint8_t> content((const uint8_t *)sectionContents.data(),
-                            sectionContents.size());
   auto *newAtom = new (_readerStorage) ELFDefinedAtom<ELFT>(
       *this, "", sectionName, sym, section, content, 0, 0, _references);
   newAtom->setOrdinal(++_ordinal);





More information about the llvm-commits mailing list