From 066fea0d2588711b8daa0510658b3c5a2a293ca1 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 6 Oct 2024 16:45:36 -0400 Subject: Use std::find_if() --- src/server/ingen_lv2.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/server/ingen_lv2.cpp') 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(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); -- cgit v1.2.1