-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Replace likely macro with C++20 attribute #1514
Comments
I'd like to work on it. |
@tarunsamanta2k20 Sweet :) Tell us if you need any directions. |
@tarunsamanta2k20 Are you still working on this? I would like to work on it if you are not doing it anymore. |
@heinezen should i replace all occurrences of likely and unlikely both? |
@derekfrogget if you want you may do it for 'likely' only. I am doing this only for unlikely cases. |
@tarunsamanta2k20 @derekfrogget both likely and unlikel can be replaced. There's also the same issue for the nyan repo SFTtech/nyan#105 (i think you also wanted to do this @tarunsamanta2k20 , right?) |
now it's only |
@derekfrogget (he) will do for likely. Ping him. He is also interested to work on it. |
Thanks everybody, now only the nyan repo task is left SFTtech/nyan#105 :) |
We currently use gcc's
__builtin_expect()
macro aliased asunlikely
andlikely
for static branch prediction. Primarily, this optimizes checks for parser errors. This optimizes performance for code paths which are only taken under very specific circumstances.Example:
Since C++20, the standard supports attributes that do the same thing. Additionally, they are compiler agnostic, so they should also work in clang or msvc. They should also be more readable since they don't directly wrap the condition.
Basically the code gets changed to this:
If you want to discover the codebase or really like mundane tasks, then this is an issue for you :)
Also take note of the same issue in the nyan repository: SFTtech/nyan#105
The text was updated successfully, but these errors were encountered: