From 2b7b18fb5f123bea0b7e80f1a348196dc0d36d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sun, 21 Jul 2024 22:32:14 +0200 Subject: [PATCH] Fix one and for all the ARC cache --- milli/src/update/index_documents/cache.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/milli/src/update/index_documents/cache.rs b/milli/src/update/index_documents/cache.rs index abf81f828..47f0f44b1 100644 --- a/milli/src/update/index_documents/cache.rs +++ b/milli/src/update/index_documents/cache.rs @@ -306,9 +306,10 @@ impl ArcCache { return evicted; } - // TODO not sure that I understand if self.frequent_set.contains(&key) { - self.frequent_set.get(&key); + if let Some(evicted_entry) = self.frequent_set.push(key, value) { + evicted.push(evicted_entry); + } return evicted; } @@ -335,7 +336,9 @@ impl ArcCache { }; self.p = (self.p + delta).min(self.capacity.get()); - self.replace(&key); + if let Some(evicted_entry) = self.replace(&key) { + evicted.push(evicted_entry); + } self.recent_evicted.pop(&key); if let Some(evicted_entry) = self.frequent_set.push(key, value) { evicted.push(evicted_entry);