summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-10-06 16:40:23 -0400
committerDavid Robillard <d@drobilla.net>2024-10-11 19:58:27 -0400
commit387e4faee9548a21f71a678f9e2730f6d5a307df (patch)
tree3ed0e418e86eb6c1b1cb623d4e0de5653d1f9427
parent676651dea6c22895b0bc8de18d724d716089d798 (diff)
downloadingen-387e4faee9548a21f71a678f9e2730f6d5a307df.tar.gz
ingen-387e4faee9548a21f71a678f9e2730f6d5a307df.tar.bz2
ingen-387e4faee9548a21f71a678f9e2730f6d5a307df.zip
Use std::any_of()
-rw-r--r--src/.clang-tidy1
-rw-r--r--src/LV2Features.cpp12
-rw-r--r--src/client/PortModel.cpp18
-rw-r--r--src/gui/GraphBox.cpp30
-rw-r--r--src/gui/NodeMenu.cpp15
-rw-r--r--src/server/BlockFactory.cpp16
-rw-r--r--src/server/CompiledGraph.cpp14
-rw-r--r--src/server/Engine.cpp13
8 files changed, 54 insertions, 65 deletions
diff --git a/src/.clang-tidy b/src/.clang-tidy
index 8a58aa7b..1d7809c3 100644
--- a/src/.clang-tidy
+++ b/src/.clang-tidy
@@ -26,5 +26,4 @@ Checks: >
-misc-no-recursion,
-misc-unused-parameters,
-readability-function-cognitive-complexity,
- -readability-use-anyofallof,
InheritParentConfig: true
diff --git a/src/LV2Features.cpp b/src/LV2Features.cpp
index 7d9003c0..5cdeca44 100644
--- a/src/LV2Features.cpp
+++ b/src/LV2Features.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
@@ -18,6 +18,7 @@
#include "lv2/core/lv2.h"
+#include <algorithm>
#include <cstdlib>
#include <memory>
@@ -58,12 +59,9 @@ LV2Features::is_supported(const std::string& uri) const
return true;
}
- for (const auto& f : _features) {
- if (f->uri() == uri) {
- return true;
- }
- }
- return false;
+ return std::any_of(_features.begin(),
+ _features.end(),
+ [&uri](const auto& f) { return f->uri() == uri; });
}
std::shared_ptr<LV2Features::FeatureArray>
diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp
index 48d70774..46129875 100644
--- a/src/client/PortModel.cpp
+++ b/src/client/PortModel.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
@@ -22,11 +22,11 @@
#include "ingen/client/ObjectModel.hpp"
#include "lv2/urid/urid.h"
+#include <algorithm>
#include <cstdint>
#include <exception>
#include <map>
#include <memory>
-#include <utility>
namespace ingen::client {
@@ -61,14 +61,12 @@ PortModel::port_property(const URIs::Quark& uri) const
bool
PortModel::is_uri() const
{
- // FIXME: Resource::has_property doesn't work, URI != URID
- for (const auto& p : properties()) {
- if (p.second.type() == _uris.atom_URID &&
- static_cast<LV2_URID>(p.second.get<int32_t>()) == _uris.atom_URID) {
- return true;
- }
- }
- return false;
+ return std::any_of(
+ properties().begin(), properties().end(), [this](const auto& p) {
+ return (p.second.type() == _uris.atom_URID &&
+ static_cast<LV2_URID>(p.second.template get<int32_t>()) ==
+ _uris.atom_URID);
+ });
}
void
diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp
index 4c3ff50d..0cbd7303 100644
--- a/src/gui/GraphBox.cpp
+++ b/src/gui/GraphBox.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2017 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
@@ -91,6 +91,7 @@
# include <webkit/webkit.h>
#endif
+#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdio>
@@ -100,7 +101,6 @@
#include <sstream>
#include <string>
#include <utility>
-#include <vector>
namespace ingen {
@@ -382,12 +382,12 @@ GraphBox::set_graph(const std::shared_ptr<const GraphModel>& graph,
_menu_view_control_window->property_sensitive() = false;
- for (const auto& p : graph->ports()) {
- if (_app->can_control(p.get())) {
- _menu_view_control_window->property_sensitive() = true;
- break;
- }
- }
+ _menu_view_control_window->property_sensitive() =
+ std::any_of(graph->ports().begin(),
+ graph->ports().end(),
+ [this](const auto& p) {
+ return _app->can_control(p.get());
+ });
_menu_parent->property_sensitive() = !!graph->parent();
@@ -425,14 +425,12 @@ GraphBox::graph_port_removed(const std::shared_ptr<const PortModel>& port)
return;
}
- for (const auto& p : _graph->ports()) {
- if (p->is_input() && _app->can_control(p.get())) {
- _menu_view_control_window->property_sensitive() = true;
- return;
- }
- }
-
- _menu_view_control_window->property_sensitive() = false;
+ _menu_view_control_window->property_sensitive() =
+ std::any_of(_graph->ports().begin(),
+ _graph->ports().end(),
+ [this](const auto& p) {
+ return p->is_input() && _app->can_control(p.get());
+ });
}
void
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index ced303fb..e18ff6b9 100644
--- a/src/gui/NodeMenu.cpp
+++ b/src/gui/NodeMenu.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
@@ -55,6 +55,7 @@
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
+#include <algorithm>
#include <cstdint>
#include <map>
#include <memory>
@@ -273,13 +274,11 @@ NodeMenu::on_preset_activated(const std::string& uri)
bool
NodeMenu::has_control_inputs()
{
- for (const auto& p : block()->ports()) {
- if (p->is_input() && p->is_numeric()) {
- return true;
- }
- }
-
- return false;
+ return std::any_of(block()->ports().begin(),
+ block()->ports().end(),
+ [](const auto& p) {
+ return p->is_input() && p->is_numeric();
+ });
}
} // namespace ingen::gui
diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp
index 87ef4a9c..124a0f61 100644
--- a/src/server/BlockFactory.cpp
+++ b/src/server/BlockFactory.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
@@ -188,13 +188,13 @@ BlockFactory::load_lv2_plugins()
const uint32_t n_ports = lilv_plugin_get_num_ports(lv2_plug);
for (uint32_t p = 0; p < n_ports; ++p) {
const LilvPort* port = lilv_plugin_get_port_by_index(lv2_plug, p);
- supported = false;
- for (const auto& t : types) {
- if (lilv_port_is_a(lv2_plug, port, t.get())) {
- supported = true;
- break;
- }
- }
+ supported =
+ std::any_of(types.begin(),
+ types.end(),
+ [&lv2_plug, &port](const auto& t) {
+ return lilv_port_is_a(lv2_plug, port, t.get());
+ });
+
if (!supported &&
!lilv_port_has_property(lv2_plug,
port,
diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp
index a89623d0..73468481 100644
--- a/src/server/CompiledGraph.cpp
+++ b/src/server/CompiledGraph.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2015-2017 David Robillard <http://drobilla.net/>
+ Copyright 2015-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
@@ -61,13 +61,11 @@ public:
static bool
has_provider_with_many_dependants(const BlockImpl* n)
{
- for (const auto* p : n->providers()) {
- if (p->dependants().size() > 1) {
- return true;
- }
- }
-
- return false;
+ return std::any_of(n->providers().begin(),
+ n->providers().end(),
+ [](const auto* p) {
+ return p->dependants().size() > 1;
+ });
}
CompiledGraph::CompiledGraph(GraphImpl* graph)
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index cc3012d4..c9921889 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2017 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
@@ -239,12 +239,11 @@ Engine::emit_notifications(FrameTime end)
bool
Engine::pending_notifications()
{
- for (const auto& ctx : _run_contexts) {
- if (ctx->pending_notifications()) {
- return true;
- }
- }
- return false;
+ return std::any_of(_run_contexts.begin(),
+ _run_contexts.end(),
+ [](const auto& ctx) {
+ return ctx->pending_notifications();
+ });
}
bool