mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
remove the bump allocator
This commit is contained in:
parent
f6acaba061
commit
c9ff449e45
4 changed files with 20 additions and 28 deletions
|
@ -39,15 +39,15 @@ pub fn Fragment<'a>(cx: Scope<'a, FragmentProps<'a>>) -> Element {
|
|||
})
|
||||
}
|
||||
|
||||
pub struct FragmentProps<'a>(Element<'a>);
|
||||
pub struct FragmentBuilder<'a, const BUILT: bool>(Element<'a>);
|
||||
impl<'a> FragmentBuilder<'a, false> {
|
||||
pub fn children(self, children: Element<'a>) -> FragmentBuilder<'a, true> {
|
||||
pub struct FragmentProps(Element);
|
||||
pub struct FragmentBuilder<const BUILT: bool>(Element);
|
||||
impl FragmentBuilder<false> {
|
||||
pub fn children(self, children: Element) -> FragmentBuilder<true> {
|
||||
FragmentBuilder(children)
|
||||
}
|
||||
}
|
||||
impl<'a, const A: bool> FragmentBuilder<'a, A> {
|
||||
pub fn build(self) -> FragmentProps<'a> {
|
||||
impl<const A: bool> FragmentBuilder<A> {
|
||||
pub fn build(self) -> FragmentProps {
|
||||
FragmentProps(self.0)
|
||||
}
|
||||
}
|
||||
|
@ -94,11 +94,10 @@ impl<'a, const A: bool> FragmentBuilder<'a, A> {
|
|||
/// ```
|
||||
impl<'a> Properties for FragmentProps<'a> {
|
||||
type Builder = FragmentBuilder<'a, false>;
|
||||
const IS_STATIC: bool = false;
|
||||
fn builder() -> Self::Builder {
|
||||
FragmentBuilder(None)
|
||||
}
|
||||
unsafe fn memoize(&self, _other: &Self) -> bool {
|
||||
fn memoize(&self, _other: &Self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
/// static parts of the template.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct VNode<'a> {
|
||||
pub struct VNode {
|
||||
/// 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.
|
||||
pub key: Option<&'a str>,
|
||||
pub key: Option<String>,
|
||||
|
||||
/// When rendered, this template will be linked to its parent manually
|
||||
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 actual Dom
|
||||
pub root_ids: RefCell<bumpalo::collections::Vec<'a, ElementId>>,
|
||||
pub root_ids: RefCell<Vec<ElementId>>,
|
||||
|
||||
/// The dynamic parts of the template
|
||||
pub dynamic_nodes: &'a [DynamicNode<'a>],
|
||||
pub dynamic_nodes: Vec<DynamicNode>,
|
||||
|
||||
/// 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
|
||||
pub fn empty(cx: &'a ScopeState) -> Element<'a> {
|
||||
pub fn empty() -> Element {
|
||||
Some(VNode {
|
||||
key: None,
|
||||
parent: Default::default(),
|
||||
stable_id: Default::default(),
|
||||
root_ids: RefCell::new(bumpalo::collections::Vec::new_in(cx.bump())),
|
||||
dynamic_nodes: &[],
|
||||
dynamic_attrs: &[],
|
||||
root_ids: Default::default(),
|
||||
dynamic_nodes: Vec::new(),
|
||||
dynamic_attrs: Vec::new(),
|
||||
template: Cell::new(Template {
|
||||
name: "dioxus-empty",
|
||||
roots: &[],
|
||||
|
|
|
@ -32,14 +32,11 @@ use crate::innerlude::*;
|
|||
/// data: &'a str
|
||||
/// }
|
||||
/// ```
|
||||
pub trait Properties: Sized {
|
||||
pub trait Properties: Sized + 'static {
|
||||
/// The type of the builder for this component.
|
||||
/// Used to create "in-progress" versions of the props.
|
||||
type Builder;
|
||||
|
||||
/// An indication if these props are can be memoized automatically.
|
||||
const IS_STATIC: bool;
|
||||
|
||||
/// Create a builder for this component.
|
||||
fn builder() -> Self::Builder;
|
||||
|
||||
|
@ -48,16 +45,15 @@ pub trait Properties: Sized {
|
|||
/// # Safety
|
||||
/// The user must know if their props are static, but if they make a mistake, UB happens
|
||||
/// Therefore it's unsafe to memoize.
|
||||
unsafe fn memoize(&self, other: &Self) -> bool;
|
||||
fn memoize(&self, other: &Self) -> bool;
|
||||
}
|
||||
|
||||
impl Properties for () {
|
||||
type Builder = EmptyBuilder;
|
||||
const IS_STATIC: bool = true;
|
||||
fn builder() -> Self::Builder {
|
||||
EmptyBuilder {}
|
||||
}
|
||||
unsafe fn memoize(&self, _other: &Self) -> bool {
|
||||
fn memoize(&self, _other: &Self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,9 +87,6 @@ pub struct ScopeState {
|
|||
|
||||
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) hook_idx: Cell<usize>,
|
||||
|
||||
|
|
Loading…
Reference in a new issue