From 5f53935c8aa06558d23200f68419fe26eb4c392e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 25 Sep 2024 16:01:08 +0200 Subject: [PATCH] Fix a bug in the Lru --- milli/src/update/new/extract/lru.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/milli/src/update/new/extract/lru.rs b/milli/src/update/new/extract/lru.rs index 8a35cc440..7346c38af 100644 --- a/milli/src/update/new/extract/lru.rs +++ b/milli/src/update/new/extract/lru.rs @@ -121,7 +121,7 @@ struct FixedSizeListNode { #[derive(Debug)] struct FixedSizeList { nodes: Box<[Option>]>, - /// The next None in the nodes. + /// The first `None` in the nodes. next_free: usize, // TODO Also, we probably do not need one of the front and back cursors. front: usize, @@ -145,7 +145,7 @@ impl FixedSizeList { #[inline] fn len(&self) -> usize { - self.nodes.len() - self.next_free + self.next_free } #[inline] @@ -168,8 +168,9 @@ impl FixedSizeList { if self.is_full() { None } else { + let current_free = self.next_free; self.next_free += 1; - Some(self.next_free) + Some(current_free) } }