From 76ef546d4e3d11575c66e829bf34f3803277ca94 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Tue, 21 Nov 2023 10:34:47 +0100 Subject: [PATCH] fix: move only through active slots when computing distance --- include/dwarfs/detail/multi_queue_block_merger_impl.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/dwarfs/detail/multi_queue_block_merger_impl.h b/include/dwarfs/detail/multi_queue_block_merger_impl.h index 3affd2a6..ca0dcf54 100644 --- a/include/dwarfs/detail/multi_queue_block_merger_impl.h +++ b/include/dwarfs/detail/multi_queue_block_merger_impl.h @@ -161,7 +161,10 @@ class multi_queue_block_merger_impl : public block_merger_base, while (active_slots_[ix] && active_slots_[ix].value() != src) { ++distance; - ix = (ix + 1) % active_slots_.size(); + + do { + ix = (ix + 1) % active_slots_.size(); + } while (ix != active_slot_index_ && !active_slots_[ix]); if (ix == active_slot_index_) { auto it = std::find(begin(source_queue_), end(source_queue_), src);