Skip to content

Commit

Permalink
Add fast_cache2.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
elftausend committed Nov 15, 2024
1 parent cfade2f commit eecb9fe
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/cache/owned_cache/fast_cache2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use core::{any::Any, cell::RefMut, hash::BuildHasherDefault};
use crate::{LockedMap, NoHasher, State, UniqueId};

use super::Cache2;

#[derive(Default)]
pub struct FastCache2 {
pub nodes: LockedMap<UniqueId, Box<dyn Any>, BuildHasherDefault<NoHasher>>,
}

impl Cache2<Box<dyn Any>> for FastCache2 {
#[inline]
fn get_mut(&self, id: UniqueId, _len: usize) -> State<RefMut<Box<dyn Any>>> {
self.nodes.get_mut(&id)
}

fn insert(&self, id: UniqueId, _len: usize, data: Box<dyn Any>) {
self.nodes.insert(id, data);
}
}

0 comments on commit eecb9fe

Please sign in to comment.