Added overrides to fetch the execute and state interfaces without doing

a dynamic_cast<> to speed up common legacy operations.
This commit is contained in:
Aaron Giles 2010-07-02 15:42:18 +00:00
parent 553ec7f427
commit 7f11224184
2 changed files with 17 additions and 1 deletions

View File

@ -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());

View File

@ -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)