aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/transaction.rs
diff options
context:
space:
mode:
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.