Skip to content

Commit

Permalink
const-ify Dom<T>, add CompactDom<T>, simplify debug printing (closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
fschutt committed Nov 6, 2019
1 parent 1338510 commit b38fb1b
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 271 deletions.
10 changes: 5 additions & 5 deletions azul-core/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};
use crate::{
id_tree::{NodeId, NodeDataContainer},
dom::{Dom, NodeData},
dom::{CompactDom, NodeData},
};

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down Expand Up @@ -64,7 +64,7 @@ pub struct DomDiff {
}

impl DomDiff {
pub fn new<T>(old: &Dom<T>, new: &Dom<T>) -> Self {
pub fn new<T>(old: &CompactDom<T>, new: &CompactDom<T>) -> Self {

// TODO: Check if old root = new root, if not, change entire tree

Expand Down Expand Up @@ -107,7 +107,7 @@ impl DomDiff {
}

/// Formats the diff into a git-like `+ Node1 / - Node3` form
pub fn format_nicely<T>(&self, old: &Dom<T>, new: &Dom<T>) -> String {
pub fn format_nicely<T>(&self, old: &CompactDom<T>, new: &CompactDom<T>) -> String {
use self::DomChange::*;
self.changed_nodes.iter().map(|change| {
match change {
Expand Down Expand Up @@ -176,8 +176,8 @@ fn node_has_changed<T>(old: &NodeData<T>, new: &NodeData<T>) -> u8 {

fn diff_tree_inner<T>(
old_root_id: NodeId,
old: &Dom<T>,
new: &Dom<T>,
old: &CompactDom<T>,
new: &CompactDom<T>,
changes: &mut BTreeSet<DomChange>,
visited_nodes: &mut NodeDataContainer<bool>,
) {
Expand Down
Loading

0 comments on commit b38fb1b

Please sign in to comment.