mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-11-04 09:56:28 +00:00 
			
		
		
		
	Fix a bug in the Lru
This commit is contained in:
		@@ -121,7 +121,7 @@ struct FixedSizeListNode<T> {
 | 
			
		||||
#[derive(Debug)]
 | 
			
		||||
struct FixedSizeList<T> {
 | 
			
		||||
    nodes: Box<[Option<FixedSizeListNode<T>>]>,
 | 
			
		||||
    /// 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<T> FixedSizeList<T> {
 | 
			
		||||
 | 
			
		||||
    #[inline]
 | 
			
		||||
    fn len(&self) -> usize {
 | 
			
		||||
        self.nodes.len() - self.next_free
 | 
			
		||||
        self.next_free
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[inline]
 | 
			
		||||
@@ -168,8 +168,9 @@ impl<T> FixedSizeList<T> {
 | 
			
		||||
        if self.is_full() {
 | 
			
		||||
            None
 | 
			
		||||
        } else {
 | 
			
		||||
            let current_free = self.next_free;
 | 
			
		||||
            self.next_free += 1;
 | 
			
		||||
            Some(self.next_free)
 | 
			
		||||
            Some(current_free)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user