Skip to content

Commit

Permalink
address complex type clippy warning in merk cache
Browse files Browse the repository at this point in the history
  • Loading branch information
fominok committed Dec 27, 2024
1 parent 70e0aa9 commit 2749b44
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions grovedb/src/merk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ use crate::{Error, GroveDb, Transaction};

type TxMerk<'db> = Merk<PrefixedRocksDbTransactionContext<'db>>;

/// We store Merk on heap to preserve its location as well as borrow flag
/// alongside.
type CachedMerkEntry<'db> = Box<(Cell<bool>, TxMerk<'db>)>;

/// Structure to keep subtrees open in memory for repeated access.
pub(crate) struct MerkCache<'db, 'b, B: AsRef<[u8]>> {
db: &'db GroveDb,
pub(crate) version: &'db GroveVersion,
batch: Box<StorageBatch>,
tx: &'db Transaction<'db>,
merks: UnsafeCell<BTreeMap<SubtreePathBuilder<'b, B>, Box<(Cell<bool>, TxMerk<'db>)>>>,
merks: UnsafeCell<BTreeMap<SubtreePathBuilder<'b, B>, CachedMerkEntry<'db>>>,
}

impl<'db, 'b, B: AsRef<[u8]>> MerkCache<'db, 'b, B> {
Expand Down Expand Up @@ -171,7 +175,7 @@ pub(crate) struct MerkHandle<'db, 'c> {
taken_handle: &'c Cell<bool>,
}

impl<'db, 'c> MerkHandle<'db, 'c> {
impl<'db> MerkHandle<'db, '_> {
pub(crate) fn for_merk<T>(&mut self, f: impl FnOnce(&mut TxMerk<'db>) -> T) -> T {
if self.taken_handle.get() {
panic!("Attempt to have double &mut borrow on Merk");
Expand Down

0 comments on commit 2749b44

Please sign in to comment.