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

Antonio Scandurra and Nathan Sobo created

Co-Authored-By: Nathan Sobo <nathan@zed.dev>

Change summary

crates/language/src/buffer.rs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

Detailed changes

crates/language/src/buffer.rs 🔗

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