Repository navigation
Conversation
mourner
requested changes
Nov 15, 2026
mourner
left a comment
Member
There was a problem hiding this comment.
Sorry, I don't think an edge case speedup is worth this much added complexity and code, unless you can radically simplify this. Can't land it in this form.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an early exit when an enclosing-strip bound proves the current candidate is within the requested precision of optimal.
This works on rotated and chamfered polygons too, not just rectangles. If the bound isn't sufficient, the existing search runs unchanged.
Performance
Benchmarked against v2.1.0 (
Polygon | Before | After | Speedup -- | -- | -- | -- 1,000 × 1 rectangle | 277 ms | 0.0019 ms | 143,253× Rotated 100 × 1 rectangle | 48.9 ms | 0.0015 ms | 33,552× Chamfered 100 × 1 octagon | 18.3 ms | 0.0030 ms | 6,131× Rotated convex dodecagon | 566 ms | 0.0027 ms | 207,418×1d9039f) on Node 24.22.1.13,700× geometric-mean speedup across 12 thin-polygon cases. All 12 complete with just two distance probes and no queued cells.
The 15 control cases were approximately unchanged overall (1.03×), with one L-shaped polygon running 8.7% slower.
Peak memory on the 1,000 × 1 rectangle dropped from 283 MiB to 42 MiB.
Testing
Existing tests pass unchanged.
Independent geometry checks confirm the returned points and distances.
6,720 adversarial certificate attempts, with no false accepts.
No API changes or new dependencies.
The new bounds account for floating-point uncertainty and check all polygon rings, including holes.