From 21d8194c7c578dcc9535f923d10abfc7c78e0322 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 4 Dec 2015 12:32:42 +0100 Subject: [PATCH] placed cache back in new form, fixes listxml and similar (nw) --- src/emu/drivenum.cpp | 8 ++++++++ src/emu/drivenum.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/emu/drivenum.cpp b/src/emu/drivenum.cpp index a410c3fbd85..99d3498c6a4 100644 --- a/src/emu/drivenum.cpp +++ b/src/emu/drivenum.cpp @@ -189,7 +189,15 @@ machine_config &driver_enumerator::config(int index, emu_options &options) const // if we don't have it cached, add it if (m_config[index] == nullptr) { + // if our cache is full, release the head entry + if (m_config_cache.size() == CONFIG_CACHE_COUNT) + { + int first = m_config_cache.front(); + m_config[first] = nullptr; + m_config_cache.erase(m_config_cache.begin()); + } m_config[index] = std::make_unique(*s_drivers_sorted[index], options); + m_config_cache.push_back(index); } return *m_config[index]; } diff --git a/src/emu/drivenum.h b/src/emu/drivenum.h index 4768623fa7c..e3bf3117861 100644 --- a/src/emu/drivenum.h +++ b/src/emu/drivenum.h @@ -119,12 +119,15 @@ private: // internal helpers void release_current() const; + static const int CONFIG_CACHE_COUNT = 100; + // internal state int m_current; int m_filtered_count; emu_options & m_options; std::vector m_included; mutable std::vector> m_config; + mutable std::vector m_config_cache; }; #endif