don't-box-scopestates

This commit is contained in:
Evan Almloff committed 2023-01-22 15:05:32 -06:00
1 parent 75f1dc76ef
commit ba79d4babd
3 files changed
+6 -6

No files matched your search

+1 -1
View File
@@ -99,7 +99,7 @@ impl VirtualDom {
self.ensure_drop_safety(id);
if recursive {
if let Some(root) = self.scopes[id.0].as_ref().try_root_node() {
if let Some(root) = self.scopes[id.0].try_root_node() {
if let RenderReturn::Ready(node) = unsafe { root.extend_lifetime_ref() } {
self.drop_scope_inner(node)
}
+3 -3
View File
@@ -26,7 +26,7 @@ impl VirtualDom {
let height = unsafe { parent.map(|f| (*f).height + 1).unwrap_or(0) };
let id = ScopeId(entry.key());
entry.insert(Box::new(ScopeState {
entry.insert(ScopeState {
parent,
id,
height,
@@ -44,13 +44,13 @@ impl VirtualDom {
shared_contexts: Default::default(),
borrowed_props: Default::default(),
attributes_to_drop: Default::default(),
}))
})
}
fn acquire_current_scope_raw(&self) -> Option<*const ScopeState> {
let id = self.scope_stack.last().copied()?;
let scope = self.scopes.get(id.0)?;
Some(scope.as_ref())
Some(scope)
}
pub(crate) fn run_scope(&mut self, scope_id: ScopeId) -> &RenderReturn {
+2 -2
View File
@@ -177,7 +177,7 @@ use std::{any::Any, borrow::BorrowMut, cell::Cell, collections::BTreeSet, future
pub struct VirtualDom {
// Maps a template path to a map of byteindexes to templates
pub(crate) templates: FxHashMap<TemplateId, FxHashMap<usize, Template<'static>>>,
pub(crate) scopes: Slab<Box<ScopeState>>,
pub(crate) scopes: Slab<ScopeState>,
pub(crate) dirty_scopes: BTreeSet<DirtyScope>,
pub(crate) scheduler: Rc<Scheduler>,
@@ -291,7 +291,7 @@ impl VirtualDom {
///
/// This is useful for inserting or removing contexts from a scope, or rendering out its root node
pub fn get_scope(&self, id: ScopeId) -> Option<&ScopeState> {
self.scopes.get(id.0).map(|f| f.as_ref())
self.scopes.get(id.0)
}
/// Get the single scope at the top of the VirtualDom tree that will always be around