diff options
author | Wilbert Pol <wilbertpol@users.noreply.github.com> | 2015-08-01 12:46:21 +0200 |
---|---|---|
committer | Wilbert Pol <wilbertpol@users.noreply.github.com> | 2015-08-01 12:46:21 +0200 |
commit | 6f68656e05b721a4d407f48eb30ae7502943a1c3 (patch) | |
tree | cef968ddbf9141c708fa2664b6c344d440300856 | |
parent | 066a7f79181c291e428a73c723aeb57c6026c3c9 (diff) |
Some more tagmap lookup reduction work (nw)
-rw-r--r-- | src/emu/emuopts.c | 25 | ||||
-rw-r--r-- | src/emu/emuopts.h | 11 | ||||
-rw-r--r-- | src/emu/ioport.c | 9 | ||||
-rw-r--r-- | src/emu/ioport.h | 1 |
4 files changed, 37 insertions, 9 deletions
diff --git a/src/emu/emuopts.c b/src/emu/emuopts.c index fa7e48f934d..c87557ffc05 100644 --- a/src/emu/emuopts.c +++ b/src/emu/emuopts.c @@ -202,6 +202,8 @@ const options_entry emu_options::s_option_entries[] = emu_options::emu_options() : core_options() +, m_coin_impulse(0) +, m_sleep(true) { add_entries(emu_options::s_option_entries); } @@ -380,6 +382,8 @@ bool emu_options::parse_slot_devices(int argc, char *argv[], std::string &error_ result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string); } while (num != options_count()); + update_cached_options(); + return result; } @@ -393,7 +397,9 @@ bool emu_options::parse_command_line(int argc, char *argv[], std::string &error_ { // parse as normal core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string); - return parse_slot_devices(argc, argv, error_string, NULL, NULL); + bool result = parse_slot_devices(argc, argv, error_string, NULL, NULL); + update_cached_options(); + return result; } @@ -468,6 +474,8 @@ void emu_options::parse_standard_inis(std::string &error_string) // Re-evaluate slot options after loading ini files update_slot_options(); + + update_cached_options(); } @@ -570,3 +578,18 @@ const char *emu_options::sub_value(std::string &buffer, const char *name, const buffer.clear(); return buffer.c_str(); } + + +//------------------------------------------------- +// update_cached_options - to prevent tagmap +// lookups keep copies of frequently requested +// options in member variables. +//------------------------------------------------- + +void emu_options::update_cached_options() +{ + m_coin_impulse = int_value(OPTION_COIN_IMPULSE); + m_sleep = bool_value(OPTION_SLEEP); + +} + diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h index 855e8eb19af..1ce8e9d390d 100644 --- a/src/emu/emuopts.h +++ b/src/emu/emuopts.h @@ -266,7 +266,7 @@ public: int frameskip() const { return int_value(OPTION_FRAMESKIP); } int seconds_to_run() const { return int_value(OPTION_SECONDS_TO_RUN); } bool throttle() const { return bool_value(OPTION_THROTTLE); } - bool sleep() const { return bool_value(OPTION_SLEEP); } + bool sleep() const { return m_sleep; } float speed() const { return float_value(OPTION_SPEED); } bool refresh_speed() const { return bool_value(OPTION_REFRESHSPEED); } @@ -328,7 +328,7 @@ public: bool offscreen_reload() const { return bool_value(OPTION_OFFSCREEN_RELOAD); } bool natural_keyboard() const { return bool_value(OPTION_NATURAL_KEYBOARD); } bool joystick_contradictory() const { return bool_value(OPTION_JOYSTICK_CONTRADICTORY); } - int coin_impulse() const { return int_value(OPTION_COIN_IMPULSE); } + int coin_impulse() const { return m_coin_impulse; } // core debugging options bool log() const { return bool_value(OPTION_LOG); } @@ -382,7 +382,14 @@ private: // INI parsing helper bool parse_one_ini(const char *basename, int priority, std::string *error_string = NULL); + // cache frequently used options in members + void update_cached_options(); + static const options_entry s_option_entries[]; + + // cached options + int m_coin_impulse; + bool m_sleep; }; diff --git a/src/emu/ioport.c b/src/emu/ioport.c index 5743ec8578e..9777d123cfc 100644 --- a/src/emu/ioport.c +++ b/src/emu/ioport.c @@ -1917,12 +1917,13 @@ void ioport_field::frame_update(ioport_value &result, bool mouse_down) // coin impulse option int effective_impulse = m_impulse; - if (m_impulse_option_val != 0) + int impulse_option_val = machine().options().coin_impulse(); + if (impulse_option_val != 0) { - if (m_impulse_option_val < 0) + if (impulse_option_val < 0) effective_impulse = 0; else if ((m_type >= IPT_COIN1 && m_type <= IPT_COIN12) || m_impulse != 0) - effective_impulse = m_impulse_option_val; + effective_impulse = impulse_option_val; } // if this is a switch-down event, handle impulse and toggle @@ -2136,8 +2137,6 @@ void ioport_field::init_live_state(analog_field *analog) for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next()) setting->condition().initialize(setting->device()); - - m_impulse_option_val = machine().options().coin_impulse(); } diff --git a/src/emu/ioport.h b/src/emu/ioport.h index 4a4147c05d2..4839fe34272 100644 --- a/src/emu/ioport.h +++ b/src/emu/ioport.h @@ -1117,7 +1117,6 @@ private: void * m_read_param; // parameter for read callback routine ioport_field_write_delegate m_write; // write callback routine void * m_write_param; // parameter for write callback routine - int m_impulse_option_val; // impulse setting from options // data relevant to digital control types bool m_digital_value; // externally set value |