Optimize editor performance for node selection, click target bounds, and batched messages (#3162)

* Don't clone messages during batch processing

* Improve selected nodes perf and memoize network hash computation

* Reuse click target bounding boxes for document bounds

* Early terminate computing the connected count

* Cleanup
This commit is contained in:
Dennis Kobert
2025-09-11 12:08:26 +02:00
committed by GitHub
parent ad5d8fcd37
commit 5836416632
12 changed files with 97 additions and 37 deletions

View File

@@ -40,7 +40,7 @@ pub struct ClickTarget {
impl ClickTarget {
pub fn new_with_subpath(subpath: Subpath<PointId>, stroke_width: f64) -> Self {
let bounding_box = subpath.loose_bounding_box();
let bounding_box = subpath.bounding_box();
Self {
target_type: ClickTargetType::Subpath(subpath),
stroke_width,

View File

@@ -426,6 +426,11 @@ impl SegmentDomain {
self.all_connected(point).count()
}
/// Enumerate the number of segments connected to a point. If a segment starts and ends at a point then it is counted twice.
pub(crate) fn any_connected(&self, point: usize) -> bool {
self.all_connected(point).next().is_some()
}
/// Iterates over segments in the domain.
///
/// Tuple is: (id, start point, end point, handles)

View File

@@ -322,6 +322,11 @@ impl Vector {
self.point_domain.resolve_id(point).map_or(0, |point| self.segment_domain.connected_count(point))
}
/// Enumerate the number of segments connected to a point. If a segment starts and ends at a point then it is counted twice.
pub fn any_connected(&self, point: PointId) -> bool {
self.point_domain.resolve_id(point).is_some_and(|point| self.segment_domain.any_connected(point))
}
pub fn check_point_inside_shape(&self, transform: DAffine2, point: DVec2) -> bool {
let number = self
.stroke_bezpath_iter()