on master help sign in
Optimize Changeset::is_empty()
9821c4dBlaž Hrastnik
helix-core/src/transaction.rs+4−2
@@ -314,8 +314,10 @@ impl ChangeSet {
314 /// `true` when the set is empty.
314 /// `true` when the set is empty.
315 #[inline]
315 #[inline]
316 pub fn is_empty(&self) -> bool {
316 pub fn is_empty(&self) -> bool {
317− let len = self.changes.len();
317+ match self.changes.as_slice() {
318− len == 0 || (len == 1 && self.changes[0] == Operation::Retain(self.len))
318+ [] | [Operation::Retain(_)] => true,
319+ _ => false,
320+ }
319 }
321 }
320
322
321 /// Map a position through the changes.
323 /// Map a position through the changes.