mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-03 11:38:49 -06:00
PPCSymbolDB: Reduce lock contention in LoadMap/LoadMapOnBoot
By building the map in a local variable and then swapping it with the member variable, we avoid the need to hold a lock while building the map.
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
@ -49,6 +50,8 @@ bool SymbolDB::IsEmpty() const
|
||||
|
||||
bool SymbolDB::Clear(const char* prefix)
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
|
||||
// TODO: honor prefix
|
||||
m_map_name.clear();
|
||||
if (IsEmpty())
|
||||
@ -61,9 +64,14 @@ bool SymbolDB::Clear(const char* prefix)
|
||||
}
|
||||
|
||||
void SymbolDB::Index()
|
||||
{
|
||||
Index(&m_functions);
|
||||
}
|
||||
|
||||
void SymbolDB::Index(XFuncMap* functions)
|
||||
{
|
||||
int i = 0;
|
||||
for (auto& func : m_functions)
|
||||
for (auto& func : *functions)
|
||||
{
|
||||
func.second.index = i++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user