diff options
author | David Robillard <d@drobilla.net> | 2024-10-06 16:45:36 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-10-11 19:58:27 -0400 |
commit | 066fea0d2588711b8daa0510658b3c5a2a293ca1 (patch) | |
tree | 6670d02a1a663a2ffa7762571067ab3f054d8848 /src/Parser.cpp | |
parent | c07246464154e573dfea3d45cea4d00884660c6e (diff) | |
download | ingen-066fea0d2588711b8daa0510658b3c5a2a293ca1.tar.gz ingen-066fea0d2588711b8daa0510658b3c5a2a293ca1.tar.bz2 ingen-066fea0d2588711b8daa0510658b3c5a2a293ca1.zip |
Use std::find_if()
Diffstat (limited to 'src/Parser.cpp')
-rw-r--r-- | src/Parser.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Parser.cpp b/src/Parser.cpp index 2a22c31b..04a10f23 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -36,6 +36,7 @@ #include "sord/sord.h" #include "sord/sordmm.hpp" +#include <algorithm> #include <cassert> #include <cstdint> #include <cstring> @@ -633,19 +634,18 @@ Parser::parse_file(ingen::World& world, return false; } - /* Choose the graph to load. If this is a manifest, then there should only - be one, but if this is a graph file, subgraphs will be returned as well. - In this case, choose the one with the file URI. */ - URI uri; - for (const ResourceRecord& r : resources) { - if (r.uri == URI(manifest_path)) { - uri = r.uri; - file_path = r.filename; - break; - } - } + // Try to find the graph with the manifest path for a URI + const auto m = std::find_if(resources.begin(), + resources.end(), + [manifest_path](const auto& r) { + return r.uri == URI(manifest_path); + }); - if (uri.empty()) { + URI uri; + if (m != resources.end()) { + uri = m->uri; + file_path = m->filename; + } else { // Didn't find a graph with the same URI as the file, use the first uri = (*resources.begin()).uri; file_path = (*resources.begin()).filename; |