Skip to content

Commit 2fc69da

Browse files
manifest: a provider's rows as a sorted vector (two loop levels; mcpp#905's GCC defect left a set's constructor undefined)
Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent c382ae0 commit 2fc69da

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎modules/manifest/src/platform_providers.cppm‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,21 @@ std::vector<StatedProvider> stated_providers(const Statement& s, std::string_vie
9898
return out;
9999
}
100100

101+
// The rows one provider serves, each once. A sorted vector and not a set: GCC
102+
// 16.1 left a set's constructor that this unit instantiated undefined for an
103+
// importer (mcpp#905).
104+
std::vector<std::string> rows_served(const Statement& s, const StatedProvider& p) {
105+
std::vector<std::string> rows;
106+
for (auto const& pattern : p.serves) std::ranges::copy(rows_matching(s, pattern), std::back_inserter(rows));
107+
std::ranges::sort(rows);
108+
rows.erase(std::unique(rows.begin(), rows.end()), rows.end());
109+
return rows;
110+
}
111+
101112
std::vector<ServedIdentity> served_identities(const Statement& s, std::string_view name) {
102113
std::vector<ServedIdentity> out;
103-
for (auto const& p : stated_providers(s, name)) {
104-
std::set<std::string> seen;
105-
for (auto const& pattern : p.serves)
106-
for (auto& id : rows_matching(s, pattern))
107-
if (seen.insert(id).second) out.push_back({ std::move(id), p.name, p.priority });
108-
}
114+
for (auto const& p : stated_providers(s, name))
115+
for (auto const& id : rows_served(s, p)) out.push_back({ id, p.name, p.priority });
109116
std::ranges::sort(out, [](auto const& a, auto const& b) {
110117
return std::tie(a.identity, b.priority, a.provider) < std::tie(b.identity, a.priority, b.provider);
111118
});

0 commit comments

Comments
 (0)