Avoid duplicate search by reusing the iterator.

llvm-svn: 193034
This commit is contained in:
Yaron Keren 2013-10-19 09:04:26 +00:00
parent fb95582bf1
commit c98028896d
2 changed files with 7 additions and 5 deletions

View 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;
}

View 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;
}