Replace (un)likely macro with C++20 attribute #105
Labels
c++
involves C++ code
good first issue
Simple thing, suitable for newcomers
improvement
improves existing functionality
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 openage repository: SFTtech/openage#1514
The text was updated successfully, but these errors were encountered: