From b320438db4b3e4f389fa3bd0d64269088fca3822 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 1 Oct 2020 00:16:40 +1000 Subject: [PATCH] sound/discrete: Get rid of vtables in factories. This speeds up compilation. --- src/devices/sound/discrete.cpp | 10 +++---- src/devices/sound/discrete.h | 53 ++++++++++++---------------------- 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/src/devices/sound/discrete.cpp b/src/devices/sound/discrete.cpp index 82dc5e8c9e4..47e517af633 100644 --- a/src/devices/sound/discrete.cpp +++ b/src/devices/sound/discrete.cpp @@ -118,7 +118,7 @@ public: inline void unlock() { m_threadid = -1; } //const linked_list_entry *list; - node_step_list_t step_list; + discrete_device::node_step_list_t step_list; /* list of source nodes */ std::vector source_list; /* discrete_source_node */ @@ -210,10 +210,10 @@ inline void discrete_task::step_nodes() void *discrete_task::task_callback(void *param, int threadid) { - task_list_t *list = (task_list_t *) param; + const auto &list = *reinterpret_cast(param); do { - for (const auto &task : *list) + for (const auto &task : list) { /* try to lock */ if (task->lock_threadid(threadid)) @@ -601,7 +601,7 @@ void discrete_device::discrete_sanity_check(const sound_block_list_t &block_list * *************************************/ -static uint64_t list_run_time(const node_list_t &list) +static uint64_t list_run_time(const discrete_device::node_list_t &list) { uint64_t total = 0; @@ -614,7 +614,7 @@ static uint64_t list_run_time(const node_list_t &list) return total; } -static uint64_t step_list_run_time(const node_step_list_t &list) +static uint64_t step_list_run_time(const discrete_device::node_step_list_t &list) { uint64_t total = 0; diff --git a/src/devices/sound/discrete.h b/src/devices/sound/discrete.h index 87014470bbc..28097106e68 100644 --- a/src/devices/sound/discrete.h +++ b/src/devices/sound/discrete.h @@ -4101,14 +4101,10 @@ enum discrete_node_type *************************************/ struct discrete_block; -class discrete_node_base_factory; class discrete_task; class discrete_base_node; class discrete_dss_input_stream_node; class discrete_device; -typedef std::vector > node_list_t; -typedef std::vector istream_node_list_t; -typedef std::vector > task_list_t; /************************************* @@ -4137,7 +4133,6 @@ struct discrete_block const char * name; /* Node Name */ const char * mod_name; /* Module / class name */ }; -typedef std::vector sound_block_list_t; /************************************* * @@ -4154,7 +4149,6 @@ public: osd_ticks_t run_time; discrete_base_node * self; }; -typedef std::vector node_step_list_t; class discrete_input_interface { @@ -4177,7 +4171,6 @@ public: //************************************************************************** class discrete_sound_output_interface; -typedef std::vector node_output_list_t; // ======================> discrete_device @@ -4191,6 +4184,10 @@ protected: discrete_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); public: + typedef std::vector > task_list_t; + typedef std::vector > node_list_t; + typedef std::vector node_step_list_t; + // inline configuration helpers void set_intf(const discrete_block *intf) { m_intf = intf; } @@ -4231,7 +4228,6 @@ public: protected: - // device-level overrides virtual void device_start() override; virtual void device_reset() override; @@ -4253,6 +4249,8 @@ protected: node_list_t m_node_list; /* node_description * */ private: + typedef std::vector sound_block_list_t; + void discrete_build_list(const discrete_block *intf, sound_block_list_t &block_list); void discrete_sanity_check(const sound_block_list_t &block_list); void display_profiling(); @@ -4311,6 +4309,9 @@ protected: virtual void sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override; private: + typedef std::vector istream_node_list_t; + typedef std::vector node_output_list_t; + /* the output stream */ sound_stream *m_stream; @@ -4403,29 +4404,19 @@ private: discrete_sound_output_interface * m_output_intf; }; -class discrete_node_base_factory +template +class discrete_node_factory { public: - virtual std::unique_ptr Create(discrete_device &pdev, const discrete_block &block) = 0; - virtual ~discrete_node_base_factory() {} + static std::unique_ptr create(discrete_device &pdev, const discrete_block &block) + { + auto r = make_unique_clear(); + + r->init(&pdev, &block); + return r; + } }; -template -class discrete_node_factory : public discrete_node_base_factory -{ -public: - std::unique_ptr Create(discrete_device &pdev, const discrete_block &block) override; -}; - -template -std::unique_ptr discrete_node_factory::Create(discrete_device &pdev, const discrete_block &block) -{ - auto r = make_unique_clear(); - - r->init(&pdev, &block); - return r; -} - /************************************* * * Class definitions for nodes @@ -4441,16 +4432,10 @@ std::unique_ptr discrete_node_factory::Create(discrete_de * *************************************/ -template -std::unique_ptr discrete_create_node(discrete_device &pdev, const discrete_block &block) -{ - return discrete_node_factory().Create(pdev, block); -} - #define DISCRETE_SOUND_EXTERN(name) extern const discrete_block name[] #define DISCRETE_SOUND_START(name) const discrete_block name[] = { //#define DSC_SND_ENTRY(_nod, _class, _dss, _num, _iact, _iinit, _custom, _name) { _nod, new discrete_node_factory< DISCRETE_CLASS_NAME(_class) >, _dss, _num, _iact, _iinit, _custom, _name, # _class } -#define DSC_SND_ENTRY(_nod, _class, _dss, _num, _iact, _iinit, _custom, _name) { _nod, &discrete_create_node< DISCRETE_CLASS_NAME(_class) >, _dss, _num, _iact, _iinit, _custom, _name, # _class } +#define DSC_SND_ENTRY(_nod, _class, _dss, _num, _iact, _iinit, _custom, _name) { _nod, &discrete_node_factory< DISCRETE_CLASS_NAME(_class) >::create, _dss, _num, _iact, _iinit, _custom, _name, # _class } #define DISCRETE_SOUND_END DSC_SND_ENTRY( NODE_00, special, DSS_NULL , 0, DSE( NODE_NC ), DSE( 0 ) ,nullptr ,"DISCRETE_SOUND_END" ) };