From fcb0a925e20498af97682787179ac2af93a3bce0 Mon Sep 17 00:00:00 2001 From: kaltenbrunnermarkus <153593707+kaltenbrunnermarkus@users.noreply.github.com> Date: Sun, 1 Nov 2026 09:17:05 +0000 Subject: [PATCH] Sketch: hash sets for the stale-pattern check before each solve (#10493) * claim: Sketch: use a lookup map for curves in pattern upkeep * Sketch: use a lookup map for curves in pattern upkeep Pattern upkeep runs before every solve, each drag frame included, and looked up every copy curve and its arc points with a linear search over all ids. Dragging another line in a sketch with a 500-copy slot pattern spent about two thirds of each frame there. The ids now resolve through maps built once per call; the result is the same to the bit. The solve bench gains a circular slot pattern section. Co-Authored-By: Claude Opus 5.5 * Sketch: hash sets for the stale-pattern check before each solve The check whether a pattern lost a seed, copy or relation built three ordered sets of all ids before every solve. Only membership is asked, so hash sets give the same answer; a drag frame in a sketch with a 500-copy pattern takes another third less. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Markus Kaltenbrunner Co-authored-by: Claude Opus 5.5 --- crates/sketch/src/pattern.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/sketch/src/pattern.rs b/crates/sketch/src/pattern.rs index efa3650b0..92ebc1d4e 100644 --- a/crates/sketch/src/pattern.rs +++ b/crates/sketch/src/pattern.rs @@ -306,9 +306,9 @@ impl Sketch { if self.patterns.is_empty() { return; } - let curves: std::collections::BTreeSet<_> = self.curves.iter().map(|c| c.id.as_str()).collect(); - let points: std::collections::BTreeSet<_> = self.points.iter().map(|p| p.id.as_str()).collect(); - let constraint_ids: std::collections::BTreeSet<_> = self.constraints.iter().map(|c| c.id.as_str()).collect(); + let curves: std::collections::HashSet<_> = self.curves.iter().map(|c| c.id.as_str()).collect(); + let points: std::collections::HashSet<_> = self.points.iter().map(|p| p.id.as_str()).collect(); + let constraint_ids: std::collections::HashSet<_> = self.constraints.iter().map(|c| c.id.as_str()).collect(); let retired: Vec<_> = self .patterns .iter()