mirror of
https://github.com/holub/mame
synced 2025-10-06 17:08:28 +03:00
Optimise start up by delaying the state save sort and check for duplicates until all the devices have been started. This has the most visible effect on vgmplay because it registers over thirty thousand state save entries. [smf]
This commit is contained in:
parent
d1f7028027
commit
2ed5eafa69
@ -80,6 +80,14 @@ void save_manager::allow_registration(bool allowed)
|
||||
m_reg_allowed = allowed;
|
||||
if (!allowed)
|
||||
{
|
||||
// look for duplicates
|
||||
std::sort(m_entry_list.begin(), m_entry_list.end(),
|
||||
[](std::unique_ptr<state_entry> const& a, std::unique_ptr<state_entry> const& b) { return a->m_name < b->m_name; });
|
||||
|
||||
for (int i = 0; i < m_entry_list.size() - 1; i++)
|
||||
if (m_entry_list[i]->m_name == m_entry_list[i + 1]->m_name)
|
||||
fatalerror("Duplicate save state registration entry (%s)\n", m_entry_list[i]->m_name.c_str());
|
||||
|
||||
dump_registry();
|
||||
|
||||
// everything is registered by now, evaluate the savestate size
|
||||
@ -175,22 +183,8 @@ void save_manager::save_memory(device_t *device, const char *module, const char
|
||||
else
|
||||
totalname = string_format("%s/%X/%s", module, index, name);
|
||||
|
||||
// look for duplicates and an entry to insert in front of
|
||||
std::vector<std::unique_ptr<state_entry>>::iterator insert_after = m_entry_list.begin();
|
||||
for (auto it = m_entry_list.begin(); it != m_entry_list.end(); ++it)
|
||||
{
|
||||
// stop when we find an entry whose name is after ours
|
||||
if (it->get()->m_name.compare(totalname)>0)
|
||||
break;
|
||||
insert_after = it;
|
||||
|
||||
// error if we are equal
|
||||
if (it->get()->m_name.compare(totalname)==0)
|
||||
fatalerror("Duplicate save state registration entry (%s)\n", totalname.c_str());
|
||||
}
|
||||
|
||||
// insert us into the list
|
||||
m_entry_list.insert(insert_after, std::make_unique<state_entry>(val, totalname.c_str(), device, module, tag ? tag : "", index, valsize, valcount));
|
||||
m_entry_list.emplace_back(std::make_unique<state_entry>(val, totalname.c_str(), device, module, tag ? tag : "", index, valsize, valcount));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user