Skip to content

Commit 25a5f37

Browse files
Use Iterator::reduce to compose history transactions
Co-authored-by: Blaž Hrastnik <[email protected]>
1 parent 8f08375 commit 25a5f37

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

helix-core/src/history.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,9 @@ impl History {
126126
return None;
127127
}
128128

129-
let mut transaction = self.revisions[revision].transaction.clone();
130-
131129
// The bounds are checked in the if condition above:
132130
// `revision + 1` is known to be `<= self.current`.
133-
for revision in &self.revisions[revision + 1..self.current] {
134-
transaction = transaction.compose(revision.transaction.clone());
135-
}
136-
137-
Some(transaction)
131+
self.revisions[revision..self.current].iter().cloned().reduce(|acc, transaction| acc.compose(transaction))
138132
}
139133

140134
/// Undo the last edit.

0 commit comments

Comments
 (0)