Remove checks from append_subpath to improve vector editing performance (#2190)
Remove checks from append_subpath Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
1510ad820c
commit
8d0c5d305d
|
|
@ -129,10 +129,7 @@ impl PointDomain {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push(&mut self, id: PointId, position: DVec2) {
|
pub fn push(&mut self, id: PointId, position: DVec2) {
|
||||||
if self.id.contains(&id) {
|
debug_assert!(!self.id.contains(&id));
|
||||||
warn!("Duplicate point");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.id.push(id);
|
self.id.push(id);
|
||||||
self.positions.push(position);
|
self.positions.push(position);
|
||||||
}
|
}
|
||||||
|
|
@ -292,22 +289,13 @@ impl SegmentDomain {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn push(&mut self, id: SegmentId, start: usize, end: usize, handles: bezier_rs::BezierHandles, stroke: StrokeId) {
|
pub(crate) fn push(&mut self, id: SegmentId, start: usize, end: usize, handles: bezier_rs::BezierHandles, stroke: StrokeId) {
|
||||||
if self.ids.contains(&id) {
|
debug_assert!(!self.ids.contains(&id), "Tried to push an existing point to a point domain");
|
||||||
return;
|
|
||||||
}
|
self.ids.push(id);
|
||||||
// Attempt to keep line joins?
|
self.start_point.push(start);
|
||||||
let after = self.end_point.iter().copied().position(|other_end| other_end == start);
|
self.end_point.push(end);
|
||||||
let before = self.start_point.iter().copied().position(|other_start| other_start == end);
|
self.handles.push(handles);
|
||||||
let index = match (before, after) {
|
self.stroke.push(stroke);
|
||||||
(_, Some(after)) => after + 1,
|
|
||||||
(Some(before), _) => before,
|
|
||||||
(None, None) => self.ids.len(),
|
|
||||||
};
|
|
||||||
self.ids.insert(index, id);
|
|
||||||
self.start_point.insert(index, start);
|
|
||||||
self.end_point.insert(index, end);
|
|
||||||
self.handles.insert(index, handles);
|
|
||||||
self.stroke.insert(index, stroke);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn start_point_mut(&mut self) -> impl Iterator<Item = (SegmentId, &mut usize)> {
|
pub(crate) fn start_point_mut(&mut self) -> impl Iterator<Item = (SegmentId, &mut usize)> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue