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

Optimize generic is_nil #168

Closed
wants to merge 1 commit into from
Closed

Conversation

Lastique
Copy link
Member

Reduce the number of generated branches in the generic is_nil by using bitwise operations.

Note that a similar optimization is possible for operator==, but in that case there may be a slight reduction in performance if UUIDs are mostly unequal, and a slight speedup if they are mostly equal. If you're interested, I can add the change to operator== as well.

Reduce the number of generated branches in the generic `is_nil` by using bitwise operations.
@pdimov
Copy link
Member

pdimov commented Sep 16, 2024

Compilers already do this transformation by the way.

@Lastique
Copy link
Member Author

Ok, you can close it then.

I just prefer to not rely on compilers, when possible. :)

@pdimov
Copy link
Member

pdimov commented Sep 16, 2024

I'll wait for CE to have 1.86 so that I can look at the codegen (again.)

@pdimov
Copy link
Member

pdimov commented Sep 22, 2024

Now that 1.86 is on CE (somewhat, that is, not on all compilers), I could verify that this optimization is done by approximately all GCC and Clang versions we support. E.g. https://godbolt.org/z/zPoEP6xoj.

@Lastique
Copy link
Member Author

Lastique commented Sep 22, 2024

Ok, thanks.

@Lastique Lastique closed this Sep 22, 2024
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.

2 participants