inline database stream interface functions lt 64B

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-10-30 05:08:04 +00:00
parent a7cb1c5951
commit 9775694423
5 changed files with 13 additions and 0 deletions

View file

@ -71,6 +71,7 @@ impl<'a> State<'a> {
self
}
#[inline]
fn seek_fwd(&mut self) {
if !exchange(&mut self.init, false) {
self.inner.next();
@ -79,6 +80,7 @@ impl<'a> State<'a> {
}
}
#[inline]
fn seek_rev(&mut self) {
if !exchange(&mut self.init, false) {
self.inner.prev();
@ -95,6 +97,7 @@ impl<'a> State<'a> {
fn status(&self) -> Option<Error> { self.inner.status().map_err(map_err).err() }
#[inline]
fn valid(&self) -> bool { self.inner.valid() }
}

View file

@ -28,6 +28,7 @@ impl<'a> Cursor<'a, KeyVal<'a>> for Items<'a> {
fn fetch(&self) -> Option<KeyVal<'a>> { self.state.fetch().map(keyval_longevity) }
#[inline]
fn seek(&mut self) { self.state.seek_fwd(); }
}
@ -40,5 +41,6 @@ impl<'a> Stream for Items<'a> {
}
impl FusedStream for Items<'_> {
#[inline]
fn is_terminated(&self) -> bool { !self.state.init && !self.state.valid() }
}

View file

@ -28,6 +28,7 @@ impl<'a> Cursor<'a, KeyVal<'a>> for ItemsRev<'a> {
fn fetch(&self) -> Option<KeyVal<'a>> { self.state.fetch().map(keyval_longevity) }
#[inline]
fn seek(&mut self) { self.state.seek_rev(); }
}
@ -40,5 +41,6 @@ impl<'a> Stream for ItemsRev<'a> {
}
impl FusedStream for ItemsRev<'_> {
#[inline]
fn is_terminated(&self) -> bool { !self.state.init && !self.state.valid() }
}

View file

@ -26,8 +26,10 @@ impl<'a> Keys<'a> {
impl<'a> Cursor<'a, Key<'a>> for Keys<'a> {
fn state(&self) -> &State<'a> { &self.state }
#[inline]
fn fetch(&self) -> Option<Key<'a>> { self.state.fetch_key().map(slice_longevity) }
#[inline]
fn seek(&mut self) { self.state.seek_fwd(); }
}
@ -40,5 +42,6 @@ impl<'a> Stream for Keys<'a> {
}
impl FusedStream for Keys<'_> {
#[inline]
fn is_terminated(&self) -> bool { !self.state.init && !self.state.valid() }
}

View file

@ -26,8 +26,10 @@ impl<'a> KeysRev<'a> {
impl<'a> Cursor<'a, Key<'a>> for KeysRev<'a> {
fn state(&self) -> &State<'a> { &self.state }
#[inline]
fn fetch(&self) -> Option<Key<'a>> { self.state.fetch_key().map(slice_longevity) }
#[inline]
fn seek(&mut self) { self.state.seek_rev(); }
}
@ -40,5 +42,6 @@ impl<'a> Stream for KeysRev<'a> {
}
impl FusedStream for KeysRev<'_> {
#[inline]
fn is_terminated(&self) -> bool { !self.state.init && !self.state.valid() }
}