-
Notifications
You must be signed in to change notification settings - Fork 105
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
graphics/deko3d: fix and simplify rbtree code #101
Conversation
}; | ||
// This is technically UB, but basically every compiler worth using admits it as an extension | ||
return (ClassT*)((intptr_t)member - whatever{ptr}.offset); | ||
return (ClassT *)((char *)member - (char *)&((ClassT *)0->*ptr)); |
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 is still UB fwiw. I'd say the original version of this function is easier to read and does not involve dereferencing a null pointer.
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.
Reverted.
if (mode == UpperBound && node) | ||
node = walk(node, N::Right); | ||
else if (!node && parent) | ||
node = &parent->left() == &point ? parent : walk(parent, N::Right); |
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.
Is this ternary actually correct for UpperBound mode?
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.
Please let me know if there is any problem.
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 was mostly asking how did you arrive to that simplification, as I'm currently struggling to wrap my head around this code :p
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.
After some analysis, I believe this code to be correct.
Solve #100.