mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
avoid allocating for diff_kind
This commit is contained in:
parent
1163bf662c
commit
b2dfe0dc37
@ -252,20 +252,20 @@ impl<COMP: Component> VTag<COMP> {
|
||||
}
|
||||
|
||||
/// Similar to `diff_attributers` except there is only a single `kind`.
|
||||
fn diff_kind(&mut self, ancestor: &mut Option<Self>) -> Option<Patch<String, ()>> {
|
||||
fn diff_kind<'a>(&'a self, ancestor: &'a Option<Self>) -> Option<Patch<&'a str, ()>> {
|
||||
match (
|
||||
&self.kind,
|
||||
ancestor.as_mut().and_then(|anc| anc.kind.take()),
|
||||
&self.kind.as_ref(),
|
||||
ancestor.as_ref().and_then(|anc| anc.kind.as_ref()),
|
||||
) {
|
||||
(&Some(ref left), Some(ref right)) => {
|
||||
if left != right {
|
||||
Some(Patch::Replace(left.to_string(), ()))
|
||||
Some(Patch::Replace(&**left, ()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
(&Some(ref left), None) => Some(Patch::Add(left.to_string(), ())),
|
||||
(&None, Some(right)) => Some(Patch::Remove(right)),
|
||||
(&Some(ref left), None) => Some(Patch::Add(&**left, ())),
|
||||
(&None, Some(right)) => Some(Patch::Remove(&**right)),
|
||||
(&None, None) => None,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user