From 3aece4af4fccf637e5b637c37ab163add0747082 Mon Sep 17 00:00:00 2001 From: Evan Champion <110177090+evan314159@users.noreply.github.com> Date: Sun, 8 Mar 2026 08:29:47 +0800 Subject: [PATCH] Vector states correct reserved space Original code: size_t nb_states = tracks.size(); std::vector states(nb_states); initialises the vector with nb_states nulls. Later call to states.emplace_back(track.ebur128.get()) adds the EBU R128 result after the nulls. Corrected to reserve tracks.size() elements without inserting nulls. --- src/scan.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scan.cpp b/src/scan.cpp index bf792eb..a0110bd 100644 --- a/src/scan.cpp +++ b/src/scan.cpp @@ -686,8 +686,8 @@ void ScanJob::calculate_album_loudness() } else { - size_t nb_states = tracks.size(); - std::vector states(nb_states); + std::vector states; + states.reserve(tracks.size()); for (const Track &track : tracks) if (track.result.track_loudness != -HUGE_VAL) states.emplace_back(track.ebur128.get());