Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions crates/pattern-database/src/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@ impl PatternDatabase {
idx += 1;
}
}
edges.sort_by(|a, b| a.partial_cmp(b).expect("edge angle must be comparable"));
assert!(
// `total_cmp` is deterministic on NaN and never panics; NaN edges will
// simply fail the ratio-band test below and be skipped in release.
edges.sort_by(|a, b| a.total_cmp(b));
// This is an internal consistency check: the largest edge recomputed from
// the catalog vectors should match the value stored at build time. Keep it
// as a debug-only assertion so a corrupt/drifted catalog cannot crash
// release callers.
debug_assert!(
(edges[5] - catalog_largest).abs() < 1e-12,
"largest edge mismatch"
);
Expand Down
Loading