aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/transaction.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-19 05:02:12 +0000
committerNathan Vegdahl2021-07-19 05:02:12 +0000
commite462f32723bb61899a390f438d7d856d87fb7614 (patch)
treee97a9afbf07e2735ba96d62dd5e8f71e1a241fe1 /helix-core/src/transaction.rs
parent6c038bb0151c6aeb43fc94bd2dc3d516a71d346c (diff)
parent5292fe0f7df9f1a420744007aa9dd67e7a5a6610 (diff)
Merge branch 'master' into great_line_ending_and_cursor_range_cleanup
Diffstat (limited to 'helix-core/src/transaction.rs')
-rw-r--r--helix-core/src/transaction.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs
index 048839b3..e20e550f 100644
--- a/helix-core/src/transaction.rs
+++ b/helix-core/src/transaction.rs
@@ -473,11 +473,13 @@ impl Transaction {
/// Generate a transaction from a set of changes.
pub fn change<I>(doc: &Rope, changes: I) -> Self
where
- I: IntoIterator<Item = Change> + ExactSizeIterator,
+ I: IntoIterator<Item = Change> + Iterator,
{
let len = doc.len_chars();
- let mut changeset = ChangeSet::with_capacity(2 * changes.len() + 1); // rough estimate
+ let (lower, upper) = changes.size_hint();
+ let size = upper.unwrap_or(lower);
+ let mut changeset = ChangeSet::with_capacity(2 * size + 1); // rough estimate
// TODO: verify ranges are ordered and not overlapping or change will panic.