diff options
author | 2010-07-02 15:42:18 +0000 | |
---|---|---|
committer | 2010-07-02 15:42:18 +0000 | |
commit | 7f1122418454aa249f89f99ac5db6ecce55a0760 (patch) | |
tree | c8369704325344302f1eccc1aa6026a844845da1 /src | |
parent | 553ec7f42716c9bcb35d3efb0e3c903a72f640cb (diff) |
Added overrides to fetch the execute and state interfaces without doing
a dynamic_cast<> to speed up common legacy operations.
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/devintrf.c | 6 | ||||
-rw-r--r-- | src/emu/devintrf.h | 12 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index 25caae2b1bb..c7e39361618 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -683,6 +683,8 @@ void device_interface::interface_debug_setup() device_t::device_t(running_machine &_machine, const device_config &config) : machine(&_machine), m_machine(_machine), + m_execute(NULL), + m_state(NULL), m_next(NULL), m_owner((config.m_owner != NULL) ? _machine.m_devicelist.find(config.m_owner->tag()) : NULL), m_interface_list(NULL), @@ -819,6 +821,10 @@ UINT64 device_t::attotime_to_clocks(attotime duration) const void device_t::start() { + // look up the common interfaces + m_execute = dynamic_cast<device_execute_interface *>(this); + m_state = dynamic_cast<device_state_interface *>(this); + // populate the region field m_region = m_machine.region(tag()); diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index 11c7581e4d6..034111d244a 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -106,6 +106,8 @@ class device_config; class device_config_interface; class device_t; class device_interface; +class device_execute_interface; +class device_state_interface; struct rom_entry; union machine_config_token; class machine_config; @@ -365,13 +367,17 @@ public: // interface helpers template<class T> bool interface(T *&intf) { intf = dynamic_cast<T *>(this); return (intf != NULL); } - template<class T> bool next(T *&intf) const + template<class T> bool next(T *&intf) { for (device_t *cur = m_next; cur != NULL; cur = cur->m_next) if (cur->interface(intf)) return true; return false; } + + // specialized helpers + bool interface(device_execute_interface *&intf) { intf = m_execute; return (intf != NULL); } + bool interface(device_state_interface *&intf) { intf = m_state; return (intf != NULL); } // owned object helpers astring &subtag(astring &dest, const char *tag) const { return m_baseconfig.subtag(dest, tag); } @@ -430,6 +436,10 @@ protected: //------------------- end derived class overrides running_machine & m_machine; + + // for speed + device_execute_interface *m_execute; + device_state_interface *m_state; // device relationships device_t * m_next; // next device (of any type/class) |