perf(header): optimize when inserting a new type header
This commit is contained in:
@@ -58,6 +58,11 @@ impl<V: ?Sized + Any + 'static> PtrMapCell<V> {
|
||||
PtrMapCell(UnsafeCell::new(PtrMap::Empty))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_one(key: TypeId, val: Box<V>) -> PtrMapCell<V> {
|
||||
PtrMapCell(UnsafeCell::new(PtrMap::One(key, val)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get(&self, key: TypeId) -> Option<&V> {
|
||||
let map = unsafe { &*self.0.get() };
|
||||
|
||||
Reference in New Issue
Block a user