diff options
author | 2018-08-22 16:20:40 +0100 | |
---|---|---|
committer | 2018-08-22 17:21:03 +0100 | |
commit | 2ed5eafa69939491d782617d83025dff732ef99a (patch) | |
tree | 26b4dc441a83cfc8b174258aa3e26fe4f096a837 | |
parent | d1f7028027bac36a032a382846b1918ae6a837ce (diff) |
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]
-rw-r--r-- | src/emu/save.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/emu/save.cpp b/src/emu/save.cpp index 767aadb5ad9..38ad52a9a88 100644 --- a/src/emu/save.cpp +++ b/src/emu/save.cpp @@ -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)); } |