diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-05-30 13:49:56 +1000 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-05-30 13:49:56 +1000 |
| commit | 9dbcd6a5c8a9cb5c29867dd450b2af8934616f56 (patch) | |
| tree | 7160c02c623b311da496b651e61495d7ce0abb3a /src/tangara/database | |
| parent | 2ff8eac022f397bb1aed28aca376fbe422fc8b3c (diff) | |
| download | tangara-fw-9dbcd6a5c8a9cb5c29867dd450b2af8934616f56.tar.gz | |
Fix prev/next behaviour on database iterator
Fixes issue with apparent duplicated tracks in the infinite list
Diffstat (limited to 'src/tangara/database')
| -rw-r--r-- | src/tangara/database/database.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
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<Database> 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<Record>& { @@ -715,7 +714,11 @@ auto Iterator::value() const -> const std::optional<Record>& { 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); } |
