diff options
author | David Robillard <d@drobilla.net> | 2024-10-06 19:52:05 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-10-11 19:58:27 -0400 |
commit | 6be0c2c979cfffacd5a7b64e8c8318e05fe9db2a (patch) | |
tree | bb406634b07de90e2997166f7ca235e56eab48fc | |
parent | 066fea0d2588711b8daa0510658b3c5a2a293ca1 (diff) | |
download | ingen-6be0c2c979cfffacd5a7b64e8c8318e05fe9db2a.tar.gz ingen-6be0c2c979cfffacd5a7b64e8c8318e05fe9db2a.tar.bz2 ingen-6be0c2c979cfffacd5a7b64e8c8318e05fe9db2a.zip |
Use std::transform()
-rw-r--r-- | src/server/events/DisconnectAll.cpp | 39 | ||||
-rw-r--r-- | src/server/ingen_lv2.cpp | 8 |
2 files changed, 29 insertions, 18 deletions
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index 4ca6c8d6..639b289f 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -34,6 +34,8 @@ #include "ingen/Store.hpp" #include "raul/Path.hpp" +#include <algorithm> +#include <iterator> #include <memory> #include <mutex> #include <set> @@ -109,24 +111,31 @@ DisconnectAll::pre_process(PreProcessContext& ctx) } // Create disconnect events to erase adjacent arcs in parent - for (const auto& a : adjacent_arcs(_parent)) { - _impls.push_back( - new Disconnect::Impl(_engine, - _parent, - a->tail(), - dynamic_cast<InputPort*>(a->head()))); - } + const auto& arcs = adjacent_arcs(_parent); + std::transform(arcs.begin(), + arcs.end(), + std::back_inserter(_impls), + [this](const auto& a) { + return new Disconnect::Impl(_engine, + _parent, + a->tail(), + dynamic_cast<InputPort*>(a->head())); + }); // Create disconnect events to erase adjacent arcs in parent's parent if (_port && _parent->parent()) { - auto* const parent_parent = dynamic_cast<GraphImpl*>(_parent->parent()); - for (const auto& a : adjacent_arcs(parent_parent)) { - _impls.push_back( - new Disconnect::Impl(_engine, - parent_parent, - a->tail(), - dynamic_cast<InputPort*>(a->head()))); - } + auto* const grandparent = dynamic_cast<GraphImpl*>(_parent->parent()); + const auto& parent_arcs = adjacent_arcs(grandparent); + + std::transform(parent_arcs.begin(), + parent_arcs.end(), + std::back_inserter(_impls), + [this, grandparent](const auto& a) { + return new Disconnect::Impl(_engine, + grandparent, + a->tail(), + dynamic_cast<InputPort*>(a->head())); + }); } if (!_deleting && ctx.must_compile(*_parent)) { diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index f12262c1..3dcdd54d 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -65,6 +65,7 @@ #include <cstdint> #include <cstdlib> #include <cstring> +#include <iterator> #include <memory> #include <mutex> #include <set> @@ -466,9 +467,10 @@ find_graphs(const URI& manifest_uri) URI(INGEN__Graph)); Lib::Graphs graphs; - for (const auto& r : resources) { - graphs.push_back(std::make_shared<LV2Graph>(r)); - } + std::transform(resources.begin(), + resources.end(), + std::back_inserter(graphs), + [](const auto& r) { return std::make_shared<LV2Graph>(r); }); return graphs; } |