From ba79d4babdb536950ec10e569637ec8365d273be Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Sun, 22 Jan 2023 15:05:32 -0600 Subject: [PATCH] don't-box-scopestates --- packages/core/src/arena.rs | 2 +- packages/core/src/scope_arena.rs | 6 +++--- packages/core/src/virtual_dom.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/src/arena.rs b/packages/core/src/arena.rs index 75ef20ee1..25726d05b 100644 --- a/packages/core/src/arena.rs +++ b/packages/core/src/arena.rs @@ -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) } diff --git a/packages/core/src/scope_arena.rs b/packages/core/src/scope_arena.rs index 41656fe9d..1ececa01f 100644 --- a/packages/core/src/scope_arena.rs +++ b/packages/core/src/scope_arena.rs @@ -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 { diff --git a/packages/core/src/virtual_dom.rs b/packages/core/src/virtual_dom.rs index 9380bcaaf..a63e39aec 100644 --- a/packages/core/src/virtual_dom.rs +++ b/packages/core/src/virtual_dom.rs @@ -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>>, - pub(crate) scopes: Slab>, + pub(crate) scopes: Slab, pub(crate) dirty_scopes: BTreeSet, pub(crate) scheduler: Rc, @@ -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