From 9dbcd6a5c8a9cb5c29867dd450b2af8934616f56 Mon Sep 17 00:00:00 2001 From: ailurux Date: Thu, 30 May 2024 13:49:56 +1000 Subject: Fix prev/next behaviour on database iterator Fixes issue with apparent duplicated tracks in the infinite list --- src/tangara/database/database.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/tangara/database/database.cpp') diff --git a/src/tangara/database/database.cpp b/src/tangara/database/database.cpp index 4064c3ed..f7cba610 100644 --- a/src/tangara/database/database.cpp +++ b/src/tangara/database/database.cpp @@ -704,9 +704,8 @@ Iterator::Iterator(std::shared_ptr db, const IndexKey::Header& header) key_ = { .prefix = {prefix.data(), prefix.size(), &memory::kSpiRamResource}, .key = {}, - .offset = 0, + .offset = -1, }; - iterate(key_); } auto Iterator::value() const -> const std::optional& { @@ -715,7 +714,11 @@ auto Iterator::value() const -> const std::optional& { auto Iterator::next() -> void { SearchKey new_key = key_; - new_key.offset = 1; + if (new_key.offset == -1) { + new_key.offset = 0; + } else { + new_key.offset = 1; + } iterate(new_key); } -- cgit v1.2.3