Avoid duplicate search by reusing the iterator.
authorYaron Keren <yaron.keren@gmail.com>
Sat, 19 Oct 2013 09:04:26 +0000 (09:04 +0000)
committerYaron Keren <yaron.keren@gmail.com>
Sat, 19 Oct 2013 09:04:26 +0000 (09:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193034 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h

index febc81cde0b936e9ebee5adafbe75997351e1971..07de4ba8cd5f740a75ffeee5c51e775f33800ca7 100644 (file)
@@ -503,7 +503,7 @@ void RuntimeDyldImpl::resolveExternalSymbols() {
       } else {
         // We found the symbol in our global table.  It was probably in a
         // Module that we loaded previously.
-        SymbolLoc SymLoc = GlobalSymbolTable.lookup(Name);
+        SymbolLoc SymLoc = Loc->second;
         Addr = getSectionLoadAddress(SymLoc.first) + SymLoc.second;
       }
 
index 0628fa71802c55bf0028573b2e02a22c44ee4611..465d05bf2c6f253826d2cbcabe49b58671d56037 100644 (file)
@@ -308,18 +308,20 @@ public:
   void *getSymbolAddress(StringRef Name) {
     // FIXME: Just look up as a function for now. Overly simple of course.
     // Work in progress.
-    if (GlobalSymbolTable.find(Name) == GlobalSymbolTable.end())
+    SymbolTableMap::const_iterator pos = GlobalSymbolTable.find(Name);
+    if (pos == GlobalSymbolTable.end())
       return 0;
-    SymbolLoc Loc = GlobalSymbolTable.lookup(Name);
+    SymbolLoc Loc = pos->second;
     return getSectionAddress(Loc.first) + Loc.second;
   }
 
   uint64_t getSymbolLoadAddress(StringRef Name) {
     // FIXME: Just look up as a function for now. Overly simple of course.
     // Work in progress.
-    if (GlobalSymbolTable.find(Name) == GlobalSymbolTable.end())
+    SymbolTableMap::const_iterator pos = GlobalSymbolTable.find(Name);
+    if (pos == GlobalSymbolTable.end())
       return 0;
-    SymbolLoc Loc = GlobalSymbolTable.lookup(Name);
+    SymbolLoc Loc = pos->second;
     return getSectionLoadAddress(Loc.first) + Loc.second;
   }