[lld] r240178 - COFF: Cache Archive::Symbol::getName(). NFC.

Rui Ueyama ruiu at google.com
Fri Jun 19 14:25:45 PDT 2015


Author: ruiu
Date: Fri Jun 19 16:25:44 2015
New Revision: 240178

URL: http://llvm.org/viewvc/llvm-project?rev=240178&view=rev
Log:
COFF: Cache Archive::Symbol::getName(). NFC.

getName() does strlen() on the symbol table, so it's not very fast.
It's not as bad as r239332 because the number of symbols exported
from archive files are fewer than object files, and they are usually
shorter, though.

Modified:
    lld/trunk/COFF/InputFiles.cpp

Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=240178&r1=240177&r2=240178&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Fri Jun 19 16:25:44 2015
@@ -61,10 +61,10 @@ std::error_code ArchiveFile::parse() {
   // Read the symbol table to construct Lazy objects.
   uint32_t I = 0;
   for (const Archive::Symbol &Sym : File->symbols()) {
+    auto *B = new (&Buf[I++]) Lazy(this, Sym);
     // Skip special symbol exists in import library files.
-    if (Sym.getName() == "__NULL_IMPORT_DESCRIPTOR")
-      continue;
-    SymbolBodies.push_back(new (&Buf[I++]) Lazy(this, Sym));
+    if (B->getName() != "__NULL_IMPORT_DESCRIPTOR")
+      SymbolBodies.push_back(B);
   }
   return std::error_code();
 }





More information about the llvm-commits mailing list