From f323fc48d71f1f5768102f665329624595e88591 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 13 Mar 2023 13:44:58 +0100 Subject: [PATCH] pcm/Normalizer: eliminate the local variable `slot` --- src/pcm/Normalizer.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pcm/Normalizer.cxx b/src/pcm/Normalizer.cxx index de1cf893d..27ba50e20 100644 --- a/src/pcm/Normalizer.cxx +++ b/src/pcm/Normalizer.cxx @@ -15,8 +15,6 @@ PcmNormalizer::ProcessS16(int16_t *gcc_restrict dest, constexpr SampleFormat format = SampleFormat::S16; using Traits = SampleTraits; - const int slot = (pos + 1) % bufsz; - int peakVal = 1, peakPos = 0; for (std::size_t i = 0; i < src.size(); i++) { int val = src[i]; @@ -28,7 +26,9 @@ PcmNormalizer::ProcessS16(int16_t *gcc_restrict dest, peakPos = i; } } - peaks[slot] = peakVal; + + pos = (pos + 1) % bufsz; + peaks[pos] = peakVal; for (std::size_t i = 0; i < bufsz; i++) { if (peaks[i] > peakVal) @@ -85,6 +85,4 @@ PcmNormalizer::ProcessS16(int16_t *gcc_restrict dest, //! Amplify the sample *dest++ = PcmClamp(sample * curGain >> 10); } - - pos = slot; }