perf: remove global allocation for props
This commit is contained in:
1 parent
369b36b2c6
commit
8b3ac0b57c
15 files changed
+352
-105
No files matched your search
@@ -1,4 +1,5 @@
|
||||
//! Prove that the dom works normally through virtualdom methods.
|
||||
//!
|
||||
//! This methods all use "rebuild" which completely bypasses the scheduler.
|
||||
//! Hard rebuilds don't consume any events from the event queue.
|
||||
|
||||
@@ -45,8 +46,8 @@ fn test_original_diff() {
|
||||
);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
async fn create() {
|
||||
#[test]
|
||||
fn create() {
|
||||
static APP: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
@@ -96,8 +97,8 @@ async fn create() {
|
||||
);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
async fn create_list() {
|
||||
#[test]
|
||||
fn create_list() {
|
||||
static APP: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
{(0..3).map(|f| rsx!{ div {
|
||||
@@ -136,8 +137,8 @@ async fn create_list() {
|
||||
);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
async fn create_simple() {
|
||||
#[test]
|
||||
fn create_simple() {
|
||||
static APP: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
div {}
|
||||
@@ -162,9 +163,8 @@ async fn create_simple() {
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
async fn create_components() {
|
||||
#[test]
|
||||
fn create_components() {
|
||||
static App: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
Child { "abc1" }
|
||||
@@ -215,9 +215,8 @@ async fn create_components() {
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
async fn anchors() {
|
||||
#[test]
|
||||
fn anchors() {
|
||||
static App: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
{true.then(|| rsx!{ div { "hello" } })}
|
||||
@@ -242,8 +241,8 @@ async fn anchors() {
|
||||
);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
async fn suspended() {
|
||||
#[test]
|
||||
fn suspended() {
|
||||
static App: FC<()> = |cx| {
|
||||
let val = use_suspense(
|
||||
cx,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//! test that we can display the virtualdom properly
|
||||
//!
|
||||
//!
|
||||
//!
|
||||
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_core as dioxus;
|
||||
use dioxus_html as dioxus_elements;
|
||||
mod test_logging;
|
||||
|
||||
const IS_LOGGING_ENABLED: bool = true;
|
||||
|
||||
#[test]
|
||||
fn please_work() {
|
||||
static App: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
hidden: "true"
|
||||
"hello"
|
||||
div { "hello" }
|
||||
Child {}
|
||||
Child {}
|
||||
Child {}
|
||||
}
|
||||
div { "hello" }
|
||||
})
|
||||
};
|
||||
|
||||
static Child: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
div { "child" }
|
||||
})
|
||||
};
|
||||
|
||||
let mut dom = VirtualDom::new(App);
|
||||
dom.rebuild();
|
||||
|
||||
println!("{}", dom);
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_core as dioxus;
|
||||
use dioxus_html as dioxus_elements;
|
||||
|
||||
type Shared<T> = Rc<RefCell<T>>;
|
||||
|
||||
#[test]
|
||||
fn sample_refs() {
|
||||
|
||||
// static App: FC<()> = |cx| {
|
||||
// let div_ref = use_node_ref::<MyRef, _>(cx);
|
||||
|
||||
|
||||
@@ -1 +1,43 @@
|
||||
//! Tests for the lifecycle of components.
|
||||
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_core as dioxus;
|
||||
use dioxus_html as dioxus_elements;
|
||||
mod test_logging;
|
||||
|
||||
const IS_LOGGING_ENABLED: bool = true;
|
||||
type Shared<T> = Rc<RefCell<T>>;
|
||||
|
||||
#[test]
|
||||
fn manual_diffing() {
|
||||
#[derive(PartialEq, Props)]
|
||||
struct AppProps {
|
||||
value: Shared<&'static str>,
|
||||
}
|
||||
|
||||
static App: FC<AppProps> = |cx| {
|
||||
let val = cx.value.borrow();
|
||||
cx.render(rsx! { div { "{val}" } })
|
||||
};
|
||||
|
||||
test_logging::set_up_logging(IS_LOGGING_ENABLED);
|
||||
|
||||
let mut value = Rc::new(RefCell::new("Hello"));
|
||||
let mut dom = VirtualDom::new_with_props(
|
||||
App,
|
||||
AppProps {
|
||||
value: value.clone(),
|
||||
},
|
||||
);
|
||||
|
||||
let _ = dom.rebuild();
|
||||
|
||||
*value.borrow_mut() = "goodbye";
|
||||
|
||||
let edits = dom.diff();
|
||||
|
||||
log::debug!("edits: {:?}", edits);
|
||||
}
|
||||
@@ -1 +1,6 @@
|
||||
//! Tests for the scheduler.
|
||||
//!
|
||||
//! TODO
|
||||
//! - priority lanes
|
||||
//! - periodic checking
|
||||
//!
|
||||
Reference in new issue
Block a user