Skip to content

Commit

Permalink
#51. avoid cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed Aug 19, 2023
1 parent af486f7 commit a469264
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ impl Context {
view.commands(&mut path, self, cmds);
}

pub(crate) fn update_layout(&mut self, path: &IdPath, layout_box: LayoutBox) {
match self.layout.get_mut(path) {
Some(bref) => *bref = layout_box,
None => { self.layout.insert(path.clone(), layout_box); }
}
}

pub(crate) fn set_dirty(&mut self) {
if self.enable_dirty {
self.dirty = true
Expand Down
12 changes: 5 additions & 7 deletions src/views/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,11 @@ where

args.cx.deps.insert(id, deps);

args.cx.layout.insert(
path.clone(),
LayoutBox {
rect: LocalRect::new(LocalPoint::zero(), child_size),
offset: LocalOffset::zero(),
},
);
let layout_box = LayoutBox {
rect: LocalRect::new(LocalPoint::zero(), child_size),
offset: LocalOffset::zero(),
};
args.cx.update_layout(path, layout_box);

args.cx.id_stack.pop();
}
Expand Down

0 comments on commit a469264

Please sign in to comment.