[PATCH] D33330: COFF: Replace DLLNames maps with vectors.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 12:07:06 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL303371: COFF: Replace DLLNames maps with vectors. (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D33330?vs=99478&id=99480#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33330

Files:
  lld/trunk/COFF/DLL.cpp
  lld/trunk/COFF/DLL.h


Index: lld/trunk/COFF/DLL.cpp
===================================================================
--- lld/trunk/COFF/DLL.cpp
+++ lld/trunk/COFF/DLL.cpp
@@ -391,18 +391,15 @@
   V.insert(V.end(), Lookups.begin(), Lookups.end());
   V.insert(V.end(), Addresses.begin(), Addresses.end());
   V.insert(V.end(), Hints.begin(), Hints.end());
-  for (auto &KV : DLLNames)
-    V.push_back(KV.second);
+  V.insert(V.end(), DLLNames.begin(), DLLNames.end());
   return V;
 }
 
 void IdataContents::create() {
   std::vector<std::vector<DefinedImportData *>> V = binImports(Imports);
 
   // Create .idata contents for each DLL.
   for (std::vector<DefinedImportData *> &Syms : V) {
-    StringRef Name = Syms[0]->getDLLName();
-
     // Create lookup and address tables. If they have external names,
     // we need to create HintName chunks to store the names.
     // If they don't (if they are import-by-ordinals), we store only
@@ -428,9 +425,8 @@
       Syms[I]->setLocation(Addresses[Base + I]);
 
     // Create the import table header.
-    if (!DLLNames.count(Name))
-      DLLNames[Name] = make<StringChunk>(Name);
-    auto *Dir = make<ImportDirectoryChunk>(DLLNames[Name]);
+    DLLNames.push_back(make<StringChunk>(Syms[0]->getDLLName()));
+    auto *Dir = make<ImportDirectoryChunk>(DLLNames.back());
     Dir->LookupTab = Lookups[Base];
     Dir->AddressTab = Addresses[Base];
     Dirs.push_back(Dir);
@@ -444,8 +440,7 @@
   V.insert(V.end(), Dirs.begin(), Dirs.end());
   V.insert(V.end(), Names.begin(), Names.end());
   V.insert(V.end(), HintNames.begin(), HintNames.end());
-  for (auto &KV : DLLNames)
-    V.push_back(KV.second);
+  V.insert(V.end(), DLLNames.begin(), DLLNames.end());
   return V;
 }
 
@@ -466,12 +461,9 @@
 
   // Create .didat contents for each DLL.
   for (std::vector<DefinedImportData *> &Syms : V) {
-    StringRef Name = Syms[0]->getDLLName();
-
     // Create the delay import table header.
-    if (!DLLNames.count(Name))
-      DLLNames[Name] = make<StringChunk>(Name);
-    auto *Dir = make<DelayDirectoryChunk>(DLLNames[Name]);
+    DLLNames.push_back(make<StringChunk>(Syms[0]->getDLLName()));
+    auto *Dir = make<DelayDirectoryChunk>(DLLNames.back());
 
     size_t Base = Addresses.size();
     for (DefinedImportData *S : Syms) {
Index: lld/trunk/COFF/DLL.h
===================================================================
--- lld/trunk/COFF/DLL.h
+++ lld/trunk/COFF/DLL.h
@@ -39,7 +39,7 @@
   std::vector<Chunk *> Lookups;
   std::vector<Chunk *> Addresses;
   std::vector<Chunk *> Hints;
-  std::map<StringRef, Chunk *> DLLNames;
+  std::vector<Chunk *> DLLNames;
 };
 
 // Windows-specific.
@@ -67,7 +67,7 @@
   std::vector<Chunk *> Names;
   std::vector<Chunk *> HintNames;
   std::vector<Chunk *> Thunks;
-  std::map<StringRef, Chunk *> DLLNames;
+  std::vector<Chunk *> DLLNames;
 };
 
 // Windows-specific.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33330.99480.patch
Type: text/x-patch
Size: 2866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170518/9bec3d99/attachment.bin>


More information about the llvm-commits mailing list