Add MinMaxXYs
method to the Envelope
type
#418
Merged
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
Add
MinMaxXYs
method to theEnvelope
typeThe following pattern was frequently employed by users of the library:
This works, but has some downsides:
There is a lot of "min"/"max" stutter in the first three lines.
It feels a little more verbose than it could be.
It can be easy for subtle bugs to occur if the mins and maxes don't all line up (e.g. min is used in place of max in a single place).
The predicate in the if statement is awkward because
minOK
andmaxOK
should always have the same value. It doesn't feel right to ignore one of them though due to the asymmetry. ORing them together isn't quite correct either, since it might imply that they could be different. ANDing them together also implies that they might be different too. The problem is that there are 2 sources of truth for one logical boolean value.The new method changes this pattern to:
There's still a tiny bit of stutter between
envMin
,envMax
, andMinMaxXYs
, but there's less chance for bugs to slip in. It's one line shorter, and there are less variables overall, and there is just one boolean so the if statement is much simpler.Check List
Have you:
Added unit tests? Yes.
Add cmprefimpl tests? (if appropriate?) N/A
Updated release notes? (if appropriate?) Yes.
Related Issue
Benchmark Results
N/A, this change shouldn't have a performance impact since it's a new feature.