diff options
-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)); } |