remove the bump allocator

This commit is contained in:
Evan Almloff committed 2024-01-04 17:33:22 -06:00
1 parent f6acaba061
commit c9ff449e45
4 files changed
+20 -28

No files matched your search

+7 -8
View File
@@ -39,15 +39,15 @@ pub fn Fragment<'a>(cx: Scope<'a, FragmentProps<'a>>) -> Element {
}) })
} }
pub struct FragmentProps<'a>(Element<'a>); pub struct FragmentProps(Element);
pub struct FragmentBuilder<'a, const BUILT: bool>(Element<'a>); pub struct FragmentBuilder<const BUILT: bool>(Element);
impl<'a> FragmentBuilder<'a, false> { impl FragmentBuilder<false> {
pub fn children(self, children: Element<'a>) -> FragmentBuilder<'a, true> { pub fn children(self, children: Element) -> FragmentBuilder<true> {
FragmentBuilder(children) FragmentBuilder(children)
} }
} }
impl<'a, const A: bool> FragmentBuilder<'a, A> { impl<const A: bool> FragmentBuilder<A> {
pub fn build(self) -> FragmentProps<'a> { pub fn build(self) -> FragmentProps {
FragmentProps(self.0) FragmentProps(self.0)
} }
} }
@@ -94,11 +94,10 @@ impl<'a, const A: bool> FragmentBuilder<'a, A> {
/// ``` /// ```
impl<'a> Properties for FragmentProps<'a> { impl<'a> Properties for FragmentProps<'a> {
type Builder = FragmentBuilder<'a, false>; type Builder = FragmentBuilder<'a, false>;
const IS_STATIC: bool = false;
fn builder() -> Self::Builder { fn builder() -> Self::Builder {
FragmentBuilder(None) FragmentBuilder(None)
} }
unsafe fn memoize(&self, _other: &Self) -> bool { fn memoize(&self, _other: &Self) -> bool {
false false
} }
} }
+10 -10
View File
@@ -41,11 +41,11 @@ impl<'a> Default for RenderReturn<'a> {
/// The dynamic parts of the template are stored separately from the static parts. This allows faster diffing by skipping /// The dynamic parts of the template are stored separately from the static parts. This allows faster diffing by skipping
/// static parts of the template. /// static parts of the template.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct VNode<'a> { pub struct VNode {
/// The key given to the root of this template. /// The key given to the root of this template.
/// ///
/// In fragments, this is the key of the first child. In other cases, it is the key of the root. /// In fragments, this is the key of the first child. In other cases, it is the key of the root.
pub key: Option<&'a str>, pub key: Option<String>,
/// When rendered, this template will be linked to its parent manually /// When rendered, this template will be linked to its parent manually
pub(crate) parent: Cell<Option<ElementRef>>, pub(crate) parent: Cell<Option<ElementRef>>,
@@ -58,25 +58,25 @@ pub struct VNode<'a> {
/// The IDs for the roots of this template - to be used when moving the template around and removing it from /// The IDs for the roots of this template - to be used when moving the template around and removing it from
/// the actual Dom /// the actual Dom
pub root_ids: RefCell<bumpalo::collections::Vec<'a, ElementId>>, pub root_ids: RefCell<Vec<ElementId>>,
/// The dynamic parts of the template /// The dynamic parts of the template
pub dynamic_nodes: &'a [DynamicNode<'a>], pub dynamic_nodes: Vec<DynamicNode>,
/// The dynamic parts of the template /// The dynamic parts of the template
pub dynamic_attrs: &'a [Attribute<'a>], pub dynamic_attrs: Vec<Attribute>,
} }
impl<'a> VNode<'a> { impl VNode {
/// Create a template with no nodes that will be skipped over during diffing /// Create a template with no nodes that will be skipped over during diffing
pub fn empty(cx: &'a ScopeState) -> Element<'a> { pub fn empty() -> Element {
Some(VNode { Some(VNode {
key: None, key: None,
parent: Default::default(), parent: Default::default(),
stable_id: Default::default(), stable_id: Default::default(),
root_ids: RefCell::new(bumpalo::collections::Vec::new_in(cx.bump())), root_ids: Default::default(),
dynamic_nodes: &[], dynamic_nodes: Vec::new(),
dynamic_attrs: &[], dynamic_attrs: Vec::new(),
template: Cell::new(Template { template: Cell::new(Template {
name: "dioxus-empty", name: "dioxus-empty",
roots: &[], roots: &[],
+3 -7
View File
@@ -32,14 +32,11 @@ use crate::innerlude::*;
/// data: &'a str /// data: &'a str
/// } /// }
/// ``` /// ```
pub trait Properties: Sized { pub trait Properties: Sized + 'static {
/// The type of the builder for this component. /// The type of the builder for this component.
/// Used to create "in-progress" versions of the props. /// Used to create "in-progress" versions of the props.
type Builder; type Builder;
/// An indication if these props are can be memoized automatically.
const IS_STATIC: bool;
/// Create a builder for this component. /// Create a builder for this component.
fn builder() -> Self::Builder; fn builder() -> Self::Builder;
@@ -48,16 +45,15 @@ pub trait Properties: Sized {
/// # Safety /// # Safety
/// The user must know if their props are static, but if they make a mistake, UB happens /// The user must know if their props are static, but if they make a mistake, UB happens
/// Therefore it's unsafe to memoize. /// Therefore it's unsafe to memoize.
unsafe fn memoize(&self, other: &Self) -> bool; fn memoize(&self, other: &Self) -> bool;
} }
impl Properties for () { impl Properties for () {
type Builder = EmptyBuilder; type Builder = EmptyBuilder;
const IS_STATIC: bool = true;
fn builder() -> Self::Builder { fn builder() -> Self::Builder {
EmptyBuilder {} EmptyBuilder {}
} }
unsafe fn memoize(&self, _other: &Self) -> bool { fn memoize(&self, _other: &Self) -> bool {
true true
} }
} }
-3
View File
@@ -87,9 +87,6 @@ pub struct ScopeState {
pub(crate) render_cnt: Cell<usize>, pub(crate) render_cnt: Cell<usize>,
pub(crate) node_arena_1: BumpFrame,
pub(crate) node_arena_2: BumpFrame,
pub(crate) hooks: RefCell<Vec<Box<UnsafeCell<dyn Any>>>>, pub(crate) hooks: RefCell<Vec<Box<UnsafeCell<dyn Any>>>>,
pub(crate) hook_idx: Cell<usize>, pub(crate) hook_idx: Cell<usize>,