What is the difference between logical OR Operator(II) and nullish coalescing operator (??) in JS?
What is the difference between logical OR Operator(II) and nullish coalescing operator (??) in JS?
June 21, 2022
What is the difference between state and props?
What is the difference between state and props?
July 5, 2022

June 28, 2022

How does ‘likely’ and ‘unlikely’ attributes helps us to optimize the execution times in C++20

These attributes allow the compiler to optimize for the case where paths of execution including these statements are more or less likely than other alternative paths. This can be used if the developer knows which lines of code would most probably be executed during code execution to help the compiler increase optimization for faster execution.

if (a > b) [[likely]] {
   do_something();
} else {
   do_other();
}
while (a > 0) {
      [[unlikely]] g();
}
switch (x) {
     case one:
       f();
   break;
     case two:
    [[likely]] g()İ
   break;
     default:
        h();
} 
How does ‘likely’ and ‘unlikely’ attributes helps us to optimize the execution times in C++20
This website uses cookies to improve your experience. By using this website you agree to our Data Privacy Statement
Read more