From 8fb8427715413091ef7e31aca0a180548cd1e182 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 26 Oct 2015 17:05:10 +0000 Subject: Use a set for providers and dependants git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5790 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/BlockImpl.hpp | 10 +++++----- src/server/events/Connect.cpp | 4 ++-- src/server/events/Disconnect.cpp | 18 ++++++------------ 3 files changed, 13 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp index 06111a88..773cb115 100644 --- a/src/server/BlockImpl.hpp +++ b/src/server/BlockImpl.hpp @@ -17,7 +17,7 @@ #ifndef INGEN_ENGINE_BLOCKIMPL_HPP #define INGEN_ENGINE_BLOCKIMPL_HPP -#include +#include #include #include @@ -138,10 +138,10 @@ public: virtual PortImpl* port_by_symbol(const char* symbol); /** Blocks that are connected to this Block's inputs. */ - std::list& providers() { return _providers; } + std::set& providers() { return _providers; } /** Blocks that are connected to this Block's outputs. */ - std::list& dependants() { return _dependants; } + std::set& dependants() { return _dependants; } /** Flag block as polyphonic. * @@ -190,8 +190,8 @@ protected: Raul::Array* _ports; ///< Access in audio thread only Context::ID _context; ///< Context this block runs in uint32_t _polyphony; - std::list _providers; ///< Blocks connected to this one's input ports - std::list _dependants; ///< Blocks this one's output ports are connected to + std::set _providers; ///< Blocks connected to this one's input ports + std::set _dependants; ///< Blocks this one's output ports are connected to bool _polyphonic; bool _activated; bool _enabled; diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index 5eff8854..8880322d 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -111,8 +111,8 @@ Connect::pre_process() provider... */ if (tail_block != head_block && tail_block->parent() == head_block->parent()) { - head_block->providers().push_back(tail_block); - tail_block->dependants().push_back(head_block); + head_block->providers().insert(tail_block); + tail_block->dependants().insert(head_block); } _graph->add_arc(_arc); diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index 5634e2c2..6f84dc1a 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -72,20 +72,14 @@ Disconnect::Impl::Impl(Engine& e, BlockImpl* const tail_block = _tail->parent_block(); BlockImpl* const head_block = _head->parent_block(); - for (std::list::iterator i = head_block->providers().begin(); - i != head_block->providers().end(); ++i) { - if ((*i) == tail_block) { - head_block->providers().erase(i); - break; - } + std::set::iterator hp = head_block->providers().find(tail_block); + if (hp != head_block->providers().end()) { + head_block->providers().erase(hp); } - for (std::list::iterator i = tail_block->dependants().begin(); - i != tail_block->dependants().end(); ++i) { - if ((*i) == head_block) { - tail_block->dependants().erase(i); - break; - } + std::set::iterator td = tail_block->dependants().find(head_block); + if (td != tail_block->dependants().end()) { + tail_block->dependants().erase(td); } _head->decrement_num_arcs(); -- cgit v1.2.1