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
Bitwise operations #131
Bitwise operations #131
Conversation
…ated `equals()` The `Gizmo.generateEquals()` method used to emit direct `==` comparison even for `float` and `double` fields. This is inconsistent with how arrays of these types are compared (`Arrays.equals()`) and also with the template code IntelliJ generates. This commit changes that to bitwise comparison. Specifically, `float` comparison is now an `int` comparison of `Float.floatToIntBits`, and `double` comparison is `long` comparison of `Double.doubleToLongBits`.
I need bitwise XOR to implement The 2nd commit slightly adjusts the generated |
// this is consistent with Arrays.equals() and it's also what IntelliJ generates | ||
equals.ifIntegerEqual(equals.invokeStaticMethod(FLOAT_TO_INT_BITS, thisValue), equals.invokeStaticMethod(FLOAT_TO_INT_BITS, thatValue)) |
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.
It's pretty wild that Arrays.equals()
is doing this kind of semi-bitwise equality. 🤯
Importantly, this also makes this method consistent with Float.hashCode()
which is doing floatToIntBits
as well.
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.
Ha, I didn't even notice what Float|Double.hashCode()
does, good point.
@Ladicek do you have anything else planned or should I ship a release? |
@gsmet if you could do a release now, that would be great! I have a few changes for Quarkus waiting for my recent Gizmo improvements. I do have some more improvements in mind, but those don't block any immediate Quarkus work and are longer term anyway. |
1.4.0.Final should be available in Maven Central in ~30 minutes. |
No description provided.