CPU code optimization is always fun. Those statements are all true statements:
- Doing more isn't slower than doing less
- Simpler code isn't faster than complex code
- Executing only one logical branch in an if-else isn't faster than executing both branches and picking the right result later.
- Branching isn't slower than not branching at all.
Premature optimization includes also "obvious" things, because you'll be wrong if you don't benchmark it.
It always depends on the exact thing.
- for all of the above, which is faster may depend on the data
@amonakov and also on where the data is