From 12f0c1100dcb063e70d6cd6ab7fb9b802f12677b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 23 Nov 2022 12:20:58 +0100 Subject: [PATCH] Fix `Store` iteration bug The previous code was only correctly iterating over a single block, ignoring any others. --- crates/fj-kernel/src/storage/blocks.rs | 1 + crates/fj-kernel/src/storage/store.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/storage/blocks.rs b/crates/fj-kernel/src/storage/blocks.rs index 6f03bf021..c69b97180 100644 --- a/crates/fj-kernel/src/storage/blocks.rs +++ b/crates/fj-kernel/src/storage/blocks.rs @@ -152,6 +152,7 @@ impl Index { self.object_index.0 += 1; if self.object_index.0 >= block.len() { self.block_index.0 += 1; + self.object_index.0 = 0; } } } diff --git a/crates/fj-kernel/src/storage/store.rs b/crates/fj-kernel/src/storage/store.rs index 59cdc195c..076795b3b 100644 --- a/crates/fj-kernel/src/storage/store.rs +++ b/crates/fj-kernel/src/storage/store.rs @@ -181,7 +181,7 @@ mod tests { #[test] fn insert_and_handle() { - let store = Store::new(); + let store = Store::with_block_size(1); let object = 0; let handle = store.insert(object); @@ -191,7 +191,7 @@ mod tests { #[test] fn insert_and_iter() { - let store = Store::new(); + let store = Store::with_block_size(1); let a = store.insert(0); let b = store.insert(1);