wip: performance looks good, needs more testing
This commit is contained in:
1 parent
84b5ddded5
commit
4b6ca05f2c
9 files changed
+56
-42
No files matched your search
@@ -185,7 +185,6 @@ impl<'bump> DiffMachine<'bump> {
|
||||
/// Returns a `bool` indicating that the work completed properly.
|
||||
pub fn work(&mut self, mut deadline_expired: impl FnMut() -> bool) -> bool {
|
||||
while let Some(instruction) = self.stack.pop() {
|
||||
log::debug!("working {:?}", instruction);
|
||||
match instruction {
|
||||
DiffInstruction::Diff { old, new } => self.diff_node(old, new),
|
||||
DiffInstruction::Create { node } => self.create_node(node),
|
||||
@@ -351,6 +350,7 @@ impl<'bump> DiffMachine<'bump> {
|
||||
|
||||
// Insert a new scope into our component list
|
||||
let parent_scope = self.vdom.get_scope(parent_idx).unwrap();
|
||||
|
||||
let new_idx = self.vdom.insert_scope_with_key(|new_idx| {
|
||||
let height = parent_scope.height + 1;
|
||||
Scope::new(
|
||||
@@ -475,7 +475,7 @@ impl<'bump> DiffMachine<'bump> {
|
||||
// TODO: take a more efficient path than this
|
||||
if old.attributes.len() == new.attributes.len() {
|
||||
for (old_attr, new_attr) in old.attributes.iter().zip(new.attributes.iter()) {
|
||||
if old_attr.value != new_attr.value {
|
||||
if old_attr.value != new_attr.value || old_attr.is_volatile {
|
||||
please_commit(&mut self.mutations.edits);
|
||||
self.mutations.set_attribute(new_attr);
|
||||
}
|
||||
@@ -664,7 +664,6 @@ impl<'bump> DiffMachine<'bump> {
|
||||
// the change list stack is in the same state when this function returns.
|
||||
fn diff_non_keyed_children(&mut self, old: &'bump [VNode<'bump>], new: &'bump [VNode<'bump>]) {
|
||||
// Handled these cases in `diff_children` before calling this function.
|
||||
log::debug!("diffing non-keyed case");
|
||||
debug_assert!(!new.is_empty());
|
||||
debug_assert!(!old.is_empty());
|
||||
|
||||
|
||||
@@ -429,6 +429,11 @@ impl<'a> NodeFactory<'a> {
|
||||
is_volatile: bool,
|
||||
) -> Attribute<'a> {
|
||||
let (value, is_static) = self.raw_text(val);
|
||||
let is_volatile = match name {
|
||||
"value" | "checked" | "selected" => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
Attribute {
|
||||
name,
|
||||
value,
|
||||
|
||||
@@ -379,7 +379,7 @@ impl Scheduler {
|
||||
|
||||
log::debug!("Working finished? {:?}", work_completed);
|
||||
|
||||
log::debug!("raw edits {:?}", machine.mutations.edits);
|
||||
// log::debug!("raw edits {:?}", machine.mutations.edits);
|
||||
|
||||
let mut machine: DiffMachine<'static> = unsafe { std::mem::transmute(machine) };
|
||||
// let mut saved = machine.save();
|
||||
@@ -406,16 +406,16 @@ impl Scheduler {
|
||||
|
||||
mutations.push(new_mutations);
|
||||
|
||||
log::debug!("saved edits {:?}", mutations);
|
||||
// log::debug!("saved edits {:?}", mutations);
|
||||
|
||||
let mut saved = machine.save();
|
||||
self.save_work(saved);
|
||||
false
|
||||
true
|
||||
|
||||
// self.save_work(saved);
|
||||
// false
|
||||
} else {
|
||||
true
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ impl Scheduler {
|
||||
|
||||
while self.has_any_work() {
|
||||
// switch our priority, pop off any work
|
||||
for event in self.ui_events.drain(..) {
|
||||
while let Some(event) = self.ui_events.pop_front() {
|
||||
if let Some(scope) = self.pool.get_scope_mut(event.scope) {
|
||||
if let Some(element) = event.mounted_dom_id {
|
||||
log::info!("Calling listener {:?}, {:?}", event.scope, element);
|
||||
@@ -482,18 +482,18 @@ impl Scheduler {
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => todo!(),
|
||||
SchedulerMsg::UiEvent(e) => self.ui_events.push_back(e),
|
||||
SchedulerMsg::Task(_) => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let deadline_expired =
|
||||
self.work_on_current_lane(&mut deadline, &mut committed_mutations);
|
||||
let work_complete = self.work_on_current_lane(&mut deadline, &mut committed_mutations);
|
||||
|
||||
if deadline_expired {
|
||||
break;
|
||||
if !work_complete {
|
||||
return committed_mutations;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user