summaryrefslogtreecommitdiffstats
path: root/src/server/ingen_lv2.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-10-06 16:45:36 -0400
committerDavid Robillard <d@drobilla.net>2024-10-11 19:58:27 -0400
commit066fea0d2588711b8daa0510658b3c5a2a293ca1 (patch)
tree6670d02a1a663a2ffa7762571067ab3f054d8848 /src/server/ingen_lv2.cpp
parentc07246464154e573dfea3d45cea4d00884660c6e (diff)
downloadingen-066fea0d2588711b8daa0510658b3c5a2a293ca1.tar.gz
ingen-066fea0d2588711b8daa0510658b3c5a2a293ca1.tar.bz2
ingen-066fea0d2588711b8daa0510658b3c5a2a293ca1.zip
Use std::find_if()
Diffstat (limited to 'src/server/ingen_lv2.cpp')
-rw-r--r--src/server/ingen_lv2.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 76bdcb54..f12262c1 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -216,13 +216,12 @@ public:
virtual GraphImpl* root_graph() { return _root_graph; }
EnginePort* get_port(const raul::Path& path) override {
- for (auto& p : _ports) {
- if (p->graph_port()->path() == path) {
- return p;
- }
- }
+ const auto i =
+ std::find_if(_ports.begin(), _ports.end(), [&path](const auto& p) {
+ return p->graph_port()->path() == path;
+ });
- return nullptr;
+ return i == _ports.end() ? nullptr : *i;
}
/** Add a port. Called only during init or restore. */
@@ -522,13 +521,13 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
const Lib::Graphs graphs = find_graphs(URI(reinterpret_cast<const char*>(manifest_node.buf)));
serd_node_free(&manifest_node);
- const LV2Graph* graph = nullptr;
- for (const auto& g : graphs) {
- if (g->uri == descriptor->URI) {
- graph = g.get();
- break;
- }
- }
+ const auto g = std::find_if(graphs.begin(),
+ graphs.end(),
+ [&descriptor](const auto& graph) {
+ return graph->uri == descriptor->URI;
+ });
+
+ const LV2Graph* const graph = g == graphs.end() ? nullptr : g->get();
if (!graph) {
lv2_log_error(&logger, "could not find graph <%s>\n", descriptor->URI);