Skip to content

Commit

Permalink
Use Iterator::reduce to compose history transactions
Browse files Browse the repository at this point in the history
Co-authored-by: Blaž Hrastnik <[email protected]>
  • Loading branch information
the-mikedavis and archseer authored Nov 23, 2022
1 parent 8f08375 commit 25a5f37
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions helix-core/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,9 @@ impl History {
return None;
}

let mut transaction = self.revisions[revision].transaction.clone();

// The bounds are checked in the if condition above:
// `revision + 1` is known to be `<= self.current`.
for revision in &self.revisions[revision + 1..self.current] {
transaction = transaction.compose(revision.transaction.clone());
}

Some(transaction)
self.revisions[revision..self.current].iter().cloned().reduce(|acc, transaction| acc.compose(transaction))
}

/// Undo the last edit.
Expand Down

0 comments on commit 25a5f37

Please sign in to comment.