Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid FP arithmetic if unnecessary in CGRect.intersection(_:) #1977

Merged
merged 3 commits into from Mar 14, 2019

Conversation

Jumhyn
Copy link
Contributor

@Jumhyn Jumhyn commented Mar 7, 2019

See SR-10056 for a summary of this issue with example. The floating point arithmetic in CGRect.intersection(_:) results in a rectangle not equal to its intersection with CGRect.infinity.

@spevans
Copy link
Collaborator

spevans commented Mar 7, 2019

Could you add a unit test to this covering the example from the jira?

@Jumhyn
Copy link
Contributor Author

Jumhyn commented Mar 8, 2019

@spevans Updated!

width = overlapH.upperBound - overlapH.lowerBound
}

let height: CGFloat
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be better as a multi-ternary?

let height = overlapV == rect1SpanV ? rect1.height :
             overlapV == rect2SpanV ? rect2.height :
             overlapV.upperBound - overlapV.lowerBound

@spevans
Copy link
Collaborator

spevans commented Mar 8, 2019

@swift-ci test

@Jumhyn
Copy link
Contributor Author

Jumhyn commented Mar 11, 2019

@spevans Does the error here appear to be related to these changes? It's fairly opaque to me.

@compnerd
Copy link
Collaborator

@swift-ci please test

@Jumhyn
Copy link
Contributor Author

Jumhyn commented Mar 12, 2019

@compnerd Any idea what this failure is? I've just rebased against apple:master to see if that makes a difference.

@compnerd
Copy link
Collaborator

Unfortunately, that erases the logs, so you cannot really tell what went wrong.

@compnerd
Copy link
Collaborator

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants