Skip to content

Commit

Permalink
Use generator to filter backends.
Browse files Browse the repository at this point in the history
  • Loading branch information
crud89 committed Jan 15, 2024
1 parent 71cd29d commit aae3cf6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/AppModel/src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ void App::registerStopCallback(std::type_index type, const std::function<void()>

Enumerable<const IBackend*> App::getBackends(const BackendType type) const noexcept
{
return m_impl->m_backends |
co_yield std::ranges::elements_of(m_impl->m_backends |
std::views::transform([](const auto& backend) { return backend.second.get(); }) |
std::views::filter([type](const auto backend) { return backend->type() == type; });
std::views::filter([type](const auto backend) { return backend->type() == type; }));
}

void App::use(UniquePtr<IBackend>&& backend)
Expand Down Expand Up @@ -175,10 +175,10 @@ void App::run()
// Start the first registered rendering backend for each backend type.
for (BackendType type : VALID_BACKEND_TYPES)
{
auto backends = this->getBackends(type);

if (!backends.empty())
this->startBackend(backends.front()->typeId());
auto firstMatch = *this->getBackends(type).begin();
if (firstMatch != nullptr)
this->startBackend(firstMatch->typeId());
}

// Fire startup event.
Expand Down

0 comments on commit aae3cf6

Please sign in to comment.