mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
Make vector mesh branch detection and free-point click targets O(n) instead of O(n^2) (#4255)
* Make is_branching and free-point click targets O(n) instead of O(n^2) * usize -> u8 * Fix profiling CI treating performance improvements as regressions
This commit is contained in:
@@ -1714,8 +1714,14 @@ fn extend_targets_from_vector(targets: &mut Vec<ClickTarget>, vector_list: &List
|
||||
}
|
||||
|
||||
fn extend_free_point_targets(vector: &Vector, transform: DAffine2) -> impl Iterator<Item = ClickTarget> + '_ {
|
||||
vector.point_domain.ids().iter().filter_map(move |&point_id| {
|
||||
if vector.any_connected(point_id) {
|
||||
// Mark every point index touched by a segment endpoint in one `O(points + segments)` pass, avoiding a per-point `any_connected` scan
|
||||
let mut connected = vec![false; vector.point_domain.len()];
|
||||
for &point_index in vector.segment_domain.start_point().iter().chain(vector.segment_domain.end_point()) {
|
||||
connected[point_index] = true;
|
||||
}
|
||||
|
||||
vector.point_domain.ids().iter().enumerate().filter_map(move |(point_index, &point_id)| {
|
||||
if connected[point_index] {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user