[api] Add qgsDoubleLessThanOrNear, qgsDoubleGreaterThanOrNear, and optimize qgsDoubleNear#66419
Merged
Conversation
Allows testing for >= or <=, with a fuzzy tolerance for the equality check
This would cause undefined behavior, and shouldn't be used anyway
Move the expensive nan comparisons to last These methods are called a LOT, and the nan check is costly and unlikely
If the extent was a null extent and we tried to do operations like retrieve its width and scale it, then the extent becomes infinite. Now that we correctly handle inf values in qgsDoubleNear, this means that comparing a infinite QgsRectangle to an infinite QgsRectangle now (correctly) returns true, bypassing fallback logic that unintentionally undid the extent corruption. Just handle this correctly now by NOT trying to scale or move a null extent, which is a meaningless operation anyway.
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.
Description
For #66404 I had a need for a "is less than or roughly equal to" method. I've split those out to a separate PR for review.
While doing this, I've also added some optimisations for qgsDoubleNear (and a fix for infinite value handling which was identified in new tests written by Gemini). qgsDoubleNear frequently shows up in QGIS profiling due to how frequently it's called, and the costly isnan checks involved there. By rearranging this function a bit we can unlock some early-exit paths for the more common non-nan value checks.
AI tool usage