replace relate-based contains_properly for Line#1495
Draft
cookiedan42 wants to merge 1 commit intogeorust:mainfrom
Draft
replace relate-based contains_properly for Line#1495cookiedan42 wants to merge 1 commit intogeorust:mainfrom
cookiedan42 wants to merge 1 commit intogeorust:mainfrom
Conversation
Contributor
Author
|
This orient optimization could also be applied to |
michaelkirk
requested changes
Feb 4, 2026
Member
michaelkirk
left a comment
There was a problem hiding this comment.
The implementation looks good, but we should have some tests for this functionality. It was arguably less important before, when we were delegating to Relate which has some existing coverage.
| }; | ||
|
|
||
| rhs.coords_iter().all(|c| { | ||
| value_in_range_exclusive(c.x, x_bound.0, x_bound.1) |
Member
There was a problem hiding this comment.
I can't find any tests for line.contains_properly — that was my mistake from the original PR review. Can you add some now?
| use impl_contains_properly_geometry_for; | ||
|
|
||
| // Helper function to check value lies between min and max. | ||
| // Only makes sense if min <= max (or always false) |
Member
There was a problem hiding this comment.
Please add a debug_assert to enforce a calling contract.
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.
So this is definitely faster than the current Relate-derive baseline, but its
Line.contains_properly(Point)is also slightly faster than the existingLine.contains(Point), which have the same result. (pt intersect boundary == pt in boundary)This speedup comes from doing a little less work than running
Line.intersects(Point)N times by extracting the repeated bound ordering checks from the loopCHANGES.mdif knowledge of this change could be valuable to users.small bench speedups