Avoid allocating a Patch just to check if there are no edits

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2021-12-01 16:47:04 +01:00
parent 853b636435
commit e668ff8bcd

View file

@ -1326,8 +1326,7 @@ impl Buffer {
was_dirty: bool, was_dirty: bool,
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) { ) {
let patch = Patch::new(self.edits_since::<usize>(old_version).collect()); if self.edits_since::<usize>(old_version).next().is_none() {
if patch.is_empty() {
return; return;
} }