From eecb9fe034d178e59f77951cc6bb00725606a5e5 Mon Sep 17 00:00:00 2001 From: elftausend <76885970+elftausend@users.noreply.github.com> Date: Fri, 15 Nov 2024 20:39:59 +0100 Subject: [PATCH] Add fast_cache2.rs --- src/cache/owned_cache/fast_cache2.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/cache/owned_cache/fast_cache2.rs diff --git a/src/cache/owned_cache/fast_cache2.rs b/src/cache/owned_cache/fast_cache2.rs new file mode 100644 index 00000000..96dcac6b --- /dev/null +++ b/src/cache/owned_cache/fast_cache2.rs @@ -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, BuildHasherDefault>, +} + +impl Cache2> for FastCache2 { + #[inline] + fn get_mut(&self, id: UniqueId, _len: usize) -> State>> { + self.nodes.get_mut(&id) + } + + fn insert(&self, id: UniqueId, _len: usize, data: Box) { + self.nodes.insert(id, data); + } +}