-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix some static analysis warnings #1958
Fix some static analysis warnings #1958
Conversation
@@ -65,7 +65,7 @@ ASInterfaceState ASInterfaceStateForDisplayNode(ASDisplayNode *displayNode, UIWi | |||
// if not already, about to be set to invisible as it is not possible for an element to be visible | |||
// while outside of a window. | |||
ASInterfaceState interfaceState = displayNode.pendingInterfaceState; | |||
return (window == nil ? (interfaceState &= (~ASInterfaceStateVisible)) : interfaceState); | |||
return (window == nil ? (interfaceState & (~ASInterfaceStateVisible)) : interfaceState); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while Xcode may flag this, I think the comment above indicates its intentional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe it is intentional. The stuff about directly clearing the interface bit would be satisfied by interfaceState & (~ASInterfaceStateVisible)
. The &=
is also leaving interfaceState
different after the expression is run, but it doesn't matter because interfaceState
is never used again. This code is only working because &=
also returns the value of the newly mutated variable. You couldn't write this code in Swift, because I believe &=
doesn't return anything by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regardless, since I have no idea, but that seems more in-depth thinking is required than the other one. I think splitting this PR up is best.
For this change, I think I'd want unit tests that ensure the existing behavior persists. I've no idea how much work that would be w/o an expert weighing in on this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened a new PR for this. If you still want a unit test after reading my description, I'm happy to add one :)
@@ -2385,7 +2385,7 @@ static void ASTextDrawRun(ASTextLine *line, CTRunRef run, CGContextRef context, | |||
if (mode) { // CJK glyph, need rotated | |||
CGFloat ofs = (ascent - descent) * 0.5; | |||
CGFloat w = glyphAdvances[g].width * 0.5; | |||
CGFloat x = x = line.position.x + verticalOffset + glyphPositions[g].y + (ofs - w); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good. small diffs are terrific. Would you mind splitting this up? Thanks.
Didn't fix all of them, just a couple that were easy.