Batch anchor resolution, avoid cloning fragment ids when seeking

This commit is contained in:
Max Brunsfeld 2021-12-09 10:42:44 -08:00
parent e9c385e7a6
commit 1ed1ec21dd
3 changed files with 73 additions and 12 deletions

View file

@ -125,7 +125,18 @@ impl SelectionSet {
where
D: 'a + TextDimension<'a>,
{
self.selections.iter().map(|s| s.resolve(snapshot))
let anchors = self
.selections
.iter()
.flat_map(|selection| [&selection.start, &selection.end].into_iter());
let mut positions = snapshot.summaries_for_anchors::<D, _>(anchors);
self.selections.iter().map(move |selection| Selection {
start: positions.next().unwrap(),
end: positions.next().unwrap(),
goal: selection.goal,
reversed: selection.reversed,
id: selection.id,
})
}
pub fn intersecting_selections<'a, D, I>(