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

fix: optimize using constexpr and templates #565

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GermanAizek
Copy link

@GermanAizek GermanAizek commented May 7, 2023

@variar,
I'm not sure of course, but maybe you're interested in rewriting some parameters of functions to create guaranteed C++17 metafunctions that are more optimized due to constant conditions and variables.
I doubt that the functions I fixed have a big impact on performance, but this is a step towards using such a method for functions that are frequently called.

More info here: https://stackoverflow.com/a/57211067
My tests on godbolt here: https://godbolt.org/z/4qq9n38Tz

@variar
Copy link
Owner

variar commented May 13, 2023

As far as I understand, this removes a branch from code path at the expense of compiling separate versions of the function for different conditions. The approach might be useful. However, I'd apply it only for hot-path and after doing some measurements that justify increase in complexity/compilation time.

@GermanAizek
Copy link
Author

@variar, should I run benchmark using std::chrono?

@GermanAizek
Copy link
Author

@variar, is this pull request still relevant?

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

2 participants