[PATCH] D24200: Dispatch without hash table lookup.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 2 12:01:04 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL280524: Dispatch without hash table lookup. (authored by ruiu).

Changed prior to commit:
  https://reviews.llvm.org/D24200?vs=70199&id=70202#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24200

Files:
  lld/trunk/ELF/LinkerScript.cpp

Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -620,7 +620,6 @@
   void readExtern();
   void readGroup();
   void readInclude();
-  void readNothing() {}
   void readOutput();
   void readOutputArch();
   void readOutputFormat();
@@ -656,27 +655,11 @@
   void readGlobal(StringRef VerStr);
   void readLocal();
 
-  const static StringMap<Handler> Cmd;
   ScriptConfiguration &Opt = *ScriptConfig;
   StringSaver Saver = {ScriptConfig->Alloc};
   bool IsUnderSysroot;
 };
 
-const StringMap<elf::ScriptParser::Handler> elf::ScriptParser::Cmd = {
-    {"ENTRY", &ScriptParser::readEntry},
-    {"EXTERN", &ScriptParser::readExtern},
-    {"GROUP", &ScriptParser::readGroup},
-    {"INCLUDE", &ScriptParser::readInclude},
-    {"INPUT", &ScriptParser::readGroup},
-    {"OUTPUT", &ScriptParser::readOutput},
-    {"OUTPUT_ARCH", &ScriptParser::readOutputArch},
-    {"OUTPUT_FORMAT", &ScriptParser::readOutputFormat},
-    {"PHDRS", &ScriptParser::readPhdrs},
-    {"SEARCH_DIR", &ScriptParser::readSearchDir},
-    {"SECTIONS", &ScriptParser::readSections},
-    {"VERSION", &ScriptParser::readVersion},
-    {";", &ScriptParser::readNothing}};
-
 void ScriptParser::readVersionScript() {
   readVersionScriptCommand();
   if (!atEOF())
@@ -710,8 +693,31 @@
 void ScriptParser::readLinkerScript() {
   while (!atEOF()) {
     StringRef Tok = next();
-    if (Handler Fn = Cmd.lookup(Tok)) {
-      (this->*Fn)();
+    if (Tok == ";")
+      continue;
+
+    if (Tok == "ENTRY") {
+      readEntry();
+    } else if (Tok == "EXTERN") {
+      readExtern();
+    } else if (Tok == "GROUP" || Tok == "INPUT") {
+      readGroup();
+    } else if (Tok == "INCLUDE") {
+      readInclude();
+    } else if (Tok == "OUTPUT") {
+      readOutput();
+    } else if (Tok == "OUTPUT_ARCH") {
+      readOutputArch();
+    } else if (Tok == "OUTPUT_FORMAT") {
+      readOutputFormat();
+    } else if (Tok == "PHDRS") {
+      readPhdrs();
+    } else if (Tok == "SEARCH_DIR") {
+      readSearchDir();
+    } else if (Tok == "SECTIONS") {
+      readSections();
+    } else if (Tok == "VERSION") {
+      readVersion();
     } else if (SymbolAssignment *Cmd = readProvideOrAssignment(Tok)) {
       if (Opt.HasContents)
         Opt.Commands.emplace_back(Cmd);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24200.70202.patch
Type: text/x-patch
Size: 2384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160902/213743c5/attachment.bin>


More information about the llvm-commits mailing list