SymbolDB: Simplify GetSymbolsFromHash

Given a std::map can't have duplicate keys, iterating over the map
explicitly isn't necessary, and find() can just be used instead.

Also, instead of manually calling push_back() for every entry to
be added, the range constructor of std::vector can be used instead to add
the whole range all at once.
This commit is contained in:
Lioncash 2017-02-18 05:26:49 -05:00
parent 5814d23fd9
commit 2f2aab963d
1 changed files with 4 additions and 6 deletions

View File

@ -72,14 +72,12 @@ Symbol* SymbolDB::GetSymbolFromHash(u32 hash)
std::vector<Symbol*> SymbolDB::GetSymbolsFromHash(u32 hash)
{
std::vector<Symbol*> symbols;
const auto iter = checksumToFunction.find(hash);
for (const auto& iter : checksumToFunction)
if (iter.first == hash)
for (const auto& symbol : iter.second)
symbols.push_back(symbol);
if (iter == checksumToFunction.cend())
return {};
return symbols;
return {iter->second.cbegin(), iter->second.cend()};
}
void SymbolDB::AddCompleteSymbol(const Symbol& symbol)