From 94c2c406a4494cde29c7150627248ba8ce2485df Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 10 Feb 2025 15:33:43 -0500 Subject: Use std::min() and std::max() --- src/server/BlockImpl.cpp | 5 ++--- src/server/ControlBindings.cpp | 9 ++------- src/server/InputPort.cpp | 5 ++--- src/server/PortImpl.cpp | 4 +--- 4 files changed, 7 insertions(+), 16 deletions(-) (limited to 'src/server') diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp index b104dfb9..b4f407c3 100644 --- a/src/server/BlockImpl.cpp +++ b/src/server/BlockImpl.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -245,9 +246,7 @@ BlockImpl::process(RunContext& ctx) if (port->type() == PortType::CONTROL && port->is_input()) { const SampleCount o = port->next_value_offset( offset, ctx.nframes()); - if (o < chunk_end) { - chunk_end = o; - } + chunk_end = std::min(o, chunk_end); } } diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 8b615974..489d5384 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -38,6 +38,7 @@ #include +#include #include #include #include @@ -316,13 +317,7 @@ ControlBindings::port_value_to_control(RunContext& ctx, const float value = value_atom.get(); float normal = (value - min) / (max - min); - if (normal < 0.0f) { - normal = 0.0f; - } - - if (normal > 1.0f) { - normal = 1.0f; - } + normal = std::max(0.0f, std::min(1.0f, normal)); if (port->is_logarithmic()) { normal = logf((normal * (static_cast(M_E) - 1.0f)) + 1.0f); diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index eac62d34..01622209 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -231,9 +232,7 @@ InputPort::next_value_offset(SampleCount offset, SampleCount end) const for (const auto& arc : _arcs) { const SampleCount o = arc.tail()->next_value_offset(offset, end); - if (o < earliest) { - earliest = o; - } + earliest = std::min(o, earliest); } return earliest; diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index a812882d..f6eed11f 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -537,9 +537,7 @@ PortImpl::next_value_offset(SampleCount offset, SampleCount end) const SampleCount earliest = end; for (uint32_t v = 0; v < _poly; ++v) { const SampleCount o = _voices->at(v).buffer->next_value_offset(offset, end); - if (o < earliest) { - earliest = o; - } + earliest = std::min(o, earliest); } return earliest; } -- cgit v1.2.1