summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-10-06 16:42:58 -0400
committerDavid Robillard <d@drobilla.net>2024-10-11 19:58:27 -0400
commitc07246464154e573dfea3d45cea4d00884660c6e (patch)
treed894c17ab5d525bea51c6b6f8693bde2e4b284f3
parent387e4faee9548a21f71a678f9e2730f6d5a307df (diff)
downloadingen-c07246464154e573dfea3d45cea4d00884660c6e.tar.gz
ingen-c07246464154e573dfea3d45cea4d00884660c6e.tar.bz2
ingen-c07246464154e573dfea3d45cea4d00884660c6e.zip
Use std::count_if()
-rw-r--r--src/gui/WindowFactory.cpp14
-rw-r--r--src/server/CompiledGraph.cpp12
2 files changed, 10 insertions, 16 deletions
diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp
index 4fce885c..802fc016 100644
--- a/src/gui/WindowFactory.cpp
+++ b/src/gui/WindowFactory.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-2024 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -36,6 +36,7 @@
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
+#include <algorithm>
#include <cassert>
#include <memory>
#include <stdexcept>
@@ -93,14 +94,9 @@ WindowFactory::clear()
size_t
WindowFactory::num_open_graph_windows()
{
- size_t ret = 0;
- for (const auto& w : _graph_windows) {
- if (w.second->is_visible()) {
- ++ret;
- }
- }
-
- return ret;
+ return std::count_if(_graph_windows.begin(),
+ _graph_windows.end(),
+ [](const auto& w) { return w.second->is_visible(); });
}
GraphBox*
diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp
index 73468481..57c4537c 100644
--- a/src/server/CompiledGraph.cpp
+++ b/src/server/CompiledGraph.cpp
@@ -94,13 +94,11 @@ CompiledGraph::compile(GraphImpl& graph)
static size_t
num_unvisited_dependants(const BlockImpl* block)
{
- size_t count = 0;
- for (const BlockImpl* b : block->dependants()) {
- if (b->get_mark() == BlockImpl::Mark::UNVISITED) {
- ++count;
- }
- }
- return count;
+ return std::count_if(block->dependants().begin(),
+ block->dependants().end(),
+ [](const auto* b) {
+ return b->get_mark() == BlockImpl::Mark::UNVISITED;
+ });
}
static size_t