Skip to content

Commit

Permalink
SymbolDB: Use set to map hash with symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
sepalani committed Oct 10, 2016
1 parent e509268 commit 92a2e03
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Source/Core/Common/SymbolDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Symbol* SymbolDB::GetSymbolFromHash(u32 hash)
{
XFuncPtrMap::iterator iter = checksumToFunction.find(hash);
if (iter != checksumToFunction.end())
return iter->second;
return *iter->second.begin();
else
return nullptr;
}
Expand All @@ -76,7 +76,8 @@ std::vector<Symbol*> SymbolDB::GetSymbolsFromHash(u32 hash)

for (const auto& iter : checksumToFunction)
if (iter.first == hash)
symbols.push_back(iter.second);
for (const auto& symbol : iter.second)
symbols.push_back(symbol);

return symbols;
}
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Common/SymbolDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#pragma once

#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -57,7 +58,7 @@ class SymbolDB
{
public:
typedef std::map<u32, Symbol> XFuncMap;
typedef std::map<u32, Symbol*> XFuncPtrMap;
typedef std::map<u32, std::set<Symbol*>> XFuncPtrMap;

protected:
XFuncMap functions;
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/PPCSymbolDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Symbol* PPCSymbolDB::AddFunction(u32 startAddr)
// LOG(OSHLE, "Symbol found at %08x", startAddr);
functions[startAddr] = tempFunc;
tempFunc.type = Symbol::Type::Function;
checksumToFunction[tempFunc.hash] = &(functions[startAddr]);
checksumToFunction[tempFunc.hash].insert(&functions[startAddr]);
return &functions[startAddr];
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
if (tf.type == Symbol::Type::Function)
{
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
checksumToFunction[tf.hash] = &(functions[startAddr]);
checksumToFunction[tf.hash].insert(&functions[startAddr]);
tf.function_name = GetStrippedFunctionName(name);
}
tf.size = size;
Expand Down

0 comments on commit 92a2e03

Please sign in to comment.