From 72a87c86867e6d440ff810513f572bb7d2a646b6 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 6 Jun 2022 16:51:00 +0200 Subject: Add inline marker on a bunch of db functions --- src/db/bin/convert.rs | 4 +++- src/db/lib.rs | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/db/bin/convert.rs b/src/db/bin/convert.rs index e5778abb..9e45e61f 100644 --- a/src/db/bin/convert.rs +++ b/src/db/bin/convert.rs @@ -56,7 +56,9 @@ fn open_db(path: PathBuf, engine: String) -> Result { })?; let map_size = if u32::MAX as usize == usize::MAX { - eprintln!("LMDB is not recommended on 32-bit systems, database size will be limited"); + eprintln!( + "LMDB is not recommended on 32-bit systems, database size will be limited" + ); 1usize << 30 // 1GB for 32-bit systems } else { 1usize << 40 // 1TB for 64-bit systems diff --git a/src/db/lib.rs b/src/db/lib.rs index b9c27d9a..afea9f55 100644 --- a/src/db/lib.rs +++ b/src/db/lib.rs @@ -139,40 +139,50 @@ impl Db { #[allow(clippy::len_without_is_empty)] impl Tree { + #[inline] pub fn db(&self) -> Db { Db(self.0.clone()) } + #[inline] pub fn get>(&self, key: T) -> Result> { self.0.get(self.1, key.as_ref()) } + #[inline] pub fn len(&self) -> Result { self.0.len(self.1) } + #[inline] pub fn first(&self) -> Result> { self.iter()?.next().transpose() } + #[inline] pub fn get_gt>(&self, from: T) -> Result> { self.range((Bound::Excluded(from), Bound::Unbounded))? .next() .transpose() } + #[inline] pub fn insert, U: AsRef<[u8]>>(&self, key: T, value: U) -> Result<()> { self.0.insert(self.1, key.as_ref(), value.as_ref()) } + #[inline] pub fn remove>(&self, key: T) -> Result { self.0.remove(self.1, key.as_ref()) } + #[inline] pub fn iter(&self) -> Result> { self.0.iter(self.1) } + #[inline] pub fn iter_rev(&self) -> Result> { self.0.iter_rev(self.1) } + #[inline] pub fn range(&self, range: R) -> Result> where K: AsRef<[u8]>, @@ -182,6 +192,7 @@ impl Tree { let eb = range.end_bound(); self.0.range(self.1, get_bound(sb), get_bound(eb)) } + #[inline] pub fn range_rev(&self, range: R) -> Result> where K: AsRef<[u8]>, @@ -195,13 +206,16 @@ impl Tree { #[allow(clippy::len_without_is_empty)] impl<'a> Transaction<'a> { + #[inline] pub fn get>(&self, tree: &Tree, key: T) -> Result> { self.0.get(tree.1, key.as_ref()) } + #[inline] pub fn len(&self, tree: &Tree) -> Result { self.0.len(tree.1) } + #[inline] pub fn insert, U: AsRef<[u8]>>( &mut self, tree: &Tree, @@ -210,17 +224,21 @@ impl<'a> Transaction<'a> { ) -> Result<()> { self.0.insert(tree.1, key.as_ref(), value.as_ref()) } + #[inline] pub fn remove>(&mut self, tree: &Tree, key: T) -> Result { self.0.remove(tree.1, key.as_ref()) } + #[inline] pub fn iter(&self, tree: &Tree) -> Result> { self.0.iter(tree.1) } + #[inline] pub fn iter_rev(&self, tree: &Tree) -> Result> { self.0.iter_rev(tree.1) } + #[inline] pub fn range(&self, tree: &Tree, range: R) -> Result> where K: AsRef<[u8]>, @@ -230,6 +248,7 @@ impl<'a> Transaction<'a> { let eb = range.end_bound(); self.0.range(tree.1, get_bound(sb), get_bound(eb)) } + #[inline] pub fn range_rev(&self, tree: &Tree, range: R) -> Result> where K: AsRef<[u8]>, @@ -242,10 +261,12 @@ impl<'a> Transaction<'a> { // ---- + #[inline] pub fn abort(self, e: E) -> TxResult { Err(TxError::Abort(e)) } + #[inline] pub fn commit(self, r: R) -> TxResult { Ok(r) } -- cgit v1.2.3