diff options
author | 2021-10-09 21:58:50 +1100 | |
---|---|---|
committer | 2021-10-09 21:58:50 +1100 | |
commit | b9bd9ea99c8cce816d0107ade3fd6903be053e8c (patch) | |
tree | 42ccdd180b162cdc61c1befb5b86ad772c9bb106 | |
parent | 90b9a01adad98742e82d9df6968e71cf080db72d (diff) |
frontend: If in doubt, micro-optimise (halves startup time on Windows).
-rw-r--r-- | src/frontend/mame/ui/selgame.cpp | 56 | ||||
-rw-r--r-- | src/frontend/mame/ui/utils.cpp | 17 | ||||
-rw-r--r-- | src/frontend/mame/ui/utils.h | 9 |
3 files changed, 58 insertions, 24 deletions
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp index 12aff317f0e..93c3f3e5760 100644 --- a/src/frontend/mame/ui/selgame.cpp +++ b/src/frontend/mame/ui/selgame.cpp @@ -177,10 +177,13 @@ private: // try to load localised descriptions if (try_titles) + { load_titles(titles_file); - // populate parent descriptions while still ordered by shortname - populate_parents(); + // populate parent descriptions while still ordered by shortname + // already done on the first pass if built-in titles are used + populate_parents(); + } // get rid of the "empty" driver - we don't need positions to line up any more m_sorted_list.erase(m_sorted_list.begin() + driver_list::find(GAME_NAME(___empty))); @@ -202,36 +205,18 @@ private: game_driver const &x(*lhs.driver); game_driver const &y(*rhs.driver); - bool clonex = (x.parent[0] != '0') || x.parent[1]; - int cx = -1; - if (clonex) - { - cx = driver_list::find(x.parent); - if ((0 > cx) || (driver_list::driver(cx).flags & machine_flags::IS_BIOS_ROOT)) - clonex = false; - } - - bool cloney = (y.parent[0] != '0') || y.parent[1]; - int cy = -1; - if (cloney) - { - cy = driver_list::find(y.parent); - if ((0 > cy) || (driver_list::driver(cy).flags & machine_flags::IS_BIOS_ROOT)) - cloney = false; - } - - if (!clonex && !cloney) + if (!lhs.is_clone && !rhs.is_clone) { return compare_names(lhs.description, rhs.description); } - else if (clonex && cloney) + else if (lhs.is_clone && rhs.is_clone) { if (!std::strcmp(x.parent, y.parent)) return compare_names(lhs.description, rhs.description); else return compare_names(lhs.parent, rhs.parent); } - else if (!clonex && cloney) + else if (!lhs.is_clone && rhs.is_clone) { if (!std::strcmp(x.name, y.parent)) return true; @@ -316,6 +301,29 @@ private: if (driver.flags & machine_flags::IS_BIOS_ROOT) ++m_bios_count; + if ((driver.parent[0] != '0') || driver.parent[1]) + { + auto const parentindex(driver_list::find(driver.parent)); + if (copydesc) + { + if (0 <= parentindex) + { + game_driver const &parentdriver(driver_list::driver(parentindex)); + ins.is_clone = bool(parentdriver.flags & machine_flags::IS_BIOS_ROOT); + ins.parent = parentdriver.type.fullname(); + } + else + { + ins.is_clone = false; + ins.parent = driver.parent; + } + } + else + { + ins.is_clone = (0 <= parentindex) && !(driver_list::driver(parentindex).flags & machine_flags::IS_BIOS_ROOT); + } + } + if (copydesc) ins.description = driver.type.fullname(); @@ -386,7 +394,7 @@ private: { for (ui_system_info &info : m_sorted_list) { - if (info.driver->parent[0] != '0') + if ((info.driver->parent[0] != '0') || info.driver->parent[1]) { auto const found( std::lower_bound( diff --git a/src/frontend/mame/ui/utils.cpp b/src/frontend/mame/ui/utils.cpp index 7da3abb7111..ea41c1337ad 100644 --- a/src/frontend/mame/ui/utils.cpp +++ b/src/frontend/mame/ui/utils.cpp @@ -2140,3 +2140,20 @@ ui_software_info &ui_software_info::operator=(ui_software_info const &that) } return *this; } + + +void swap(ui_system_info &a, ui_system_info &b) noexcept +{ + using std::swap; + swap(a.driver, b.driver); + swap(a.index, b.index); + swap(a.is_clone, b.is_clone); + swap(a.available, b.available); + swap(a.description, b.description); + swap(a.parent, b.parent); + swap(a.ucs_shortname, b.ucs_shortname); + swap(a.ucs_description, b.ucs_description); + swap(a.ucs_manufacturer_description, b.ucs_manufacturer_description); + swap(a.ucs_description, b.ucs_description); + swap(a.ucs_manufacturer_default_description, b.ucs_manufacturer_default_description); +} diff --git a/src/frontend/mame/ui/utils.h b/src/frontend/mame/ui/utils.h index 184f922d7d2..496786c5f2a 100644 --- a/src/frontend/mame/ui/utils.h +++ b/src/frontend/mame/ui/utils.h @@ -32,11 +32,17 @@ class render_container; struct ui_system_info { + ui_system_info(ui_system_info const &) = default; + ui_system_info(ui_system_info &&) = default; + ui_system_info &operator=(ui_system_info const &) = default; + ui_system_info &operator=(ui_system_info &&) = default; + ui_system_info() { } ui_system_info(game_driver const &d, int i, bool a) : driver(&d), index(i), available(a) { } game_driver const *driver = nullptr; int index; + bool is_clone = false; bool available = false; std::string description; @@ -102,6 +108,9 @@ struct ui_software_info }; +void swap(ui_system_info &a, ui_system_info &b) noexcept; + + namespace ui { class machine_filter_data; |