diff options
author | Robin Gareus <robin@gareus.org> | 2018-11-03 21:55:07 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2018-11-04 02:16:34 +0100 |
commit | 51e33796f14e91b26b78f62902ea80bffa555c20 (patch) | |
tree | 6d5ce1ce7494202a8ca9fd6bf0198afe28a81d4c /libs/ardour/plugin_insert.cc | |
parent | 6bd583803ea1daf19a1c088766122b5cdf340171 (diff) |
Optimize Parameter Control Loop
For plugins with 10000 Control Inputs, dynamic_pointer_cast<> overhead
is significant, here ~2msec (~0.2usec per cast, optimized build, i7-5600U,
2.60GHz)
Diffstat (limited to 'libs/ardour/plugin_insert.cc')
-rw-r--r-- | libs/ardour/plugin_insert.cc | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 983d3b9aa8..5ecf652ce3 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -882,29 +882,20 @@ PluginInsert::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t e uint32_t n = 0; - for (Controls::iterator li = controls().begin(); li != controls().end(); ++li, ++n) { - - boost::shared_ptr<AutomationControl> c - = boost::dynamic_pointer_cast<AutomationControl>(li->second); - - if (c->list() && c->automation_playback()) { + for (Controls::const_iterator li = controls().begin(); li != controls().end(); ++li, ++n) { + + /* boost::dynamic_pointer_cast<> has significant overhead, since we know that + * all controls are AutomationControl and their lists - if any - are AutomationList, + * we can use static_cast<>. This yields a speedup of 2.8/4.6 over to the + * previous code (measuerd with VeeSeeVSTRack 10k parameters, optimized build) */ + AutomationControl& c = static_cast<AutomationControl&> (*(li->second)); + boost::shared_ptr<const Evoral::ControlList> clist (c.list()); + if (clist && (static_cast<AutomationList const&> (*clist)).automation_playback ()) { bool valid; - - const float val = c->list()->rt_safe_eval (start, valid); - + const float val = c.list()->rt_safe_eval (start, valid); if (valid) { - /* This is the ONLY place where we are - * allowed to call - * AutomationControl::set_value_unchecked(). We - * know that the control is in - * automation playback mode, so no - * check on writable() is required - * (which must be done in AutomationControl::set_value() - * - */ - c->set_value_unchecked(val); + c.set_value_unchecked(val); } - } } } |