From 228012cd0cccdf8560ba1f790c6fb78fbdb3efba Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 1 Feb 2024 22:03:13 -0500 Subject: [PATCH] Make a further deployment of `std::fill`. --- Machines/Apple/Macintosh/Audio.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Machines/Apple/Macintosh/Audio.cpp b/Machines/Apple/Macintosh/Audio.cpp index d24497990..caa312248 100644 --- a/Machines/Apple/Macintosh/Audio.cpp +++ b/Machines/Apple/Macintosh/Audio.cpp @@ -8,6 +8,8 @@ #include "Audio.hpp" +#include + using namespace Apple::Macintosh; namespace { @@ -79,11 +81,8 @@ void Audio::get_samples(std::size_t number_of_samples, int16_t *target) { const auto cycles_left_in_sample = std::min(number_of_samples, sample_length - subcycle_offset_); // Determine the output level, and output that many samples. - // (Hoping that the copiler substitutes an effective memset16-type operation here). const int16_t output_level = volume_multiplier_ * (int16_t(sample_queue_.buffer[sample_queue_.read_pointer].load(std::memory_order::memory_order_relaxed)) - 128); - for(size_t c = 0; c < cycles_left_in_sample; ++c) { - target[c] = output_level; - } + std::fill(target, target + cycles_left_in_sample, output_level); target += cycles_left_in_sample; // Advance the sample pointer.