From e470de5f0ba7b4de5f425b32ce2f4640c1026264 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Sat, 2 Nov 2024 17:22:54 -0500 Subject: [PATCH] refactor: use get_prev for Index lookup --- nomt/src/beatree/index.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nomt/src/beatree/index.rs b/nomt/src/beatree/index.rs index cd5257094f..33217da0d0 100644 --- a/nomt/src/beatree/index.rs +++ b/nomt/src/beatree/index.rs @@ -1,8 +1,7 @@ //! In-memory index tracking bottom level branch nodes. This is an immutable data structure, //! which is cheaply cloneable in O(1) and performs COW operations. -use std::iter::DoubleEndedIterator; -use std::ops::{Bound, RangeBounds, RangeToInclusive}; +use std::ops::{Bound, RangeBounds}; use std::sync::Arc; use imbl::OrdMap; @@ -21,10 +20,7 @@ impl Index { /// This is either a branch whose separator is exactly equal to this key or the branch with the /// highest separator less than the key. pub fn lookup(&self, key: Key) -> Option<(Key, Arc)> { - self.first_key_map - .range(RangeToInclusive { end: key }) - .next_back() - .map(|(sep, b)| (sep.clone(), b.clone())) + self.first_key_map.get_prev(&key).map(|(sep, b)| (sep.clone(), b.clone())) } /// Get the first branch with separator greater than the given key.