3 ms·
The performance cost of ifs are not that bad. Especially if it means you can read sequentially from the memory. It however, do represent branching, and in a ho
by hvidgaard 10y ago
The performance cost of ifs are not that bad. Especially if it means you can read sequentially from the memory.
It however, do represent branching, and in a hotspot it can be more efficient to simply calculate both the if and the else and just choose the right value, rather than having a branch misprediction.
In any case, always profile, and identify issues before doing any optimization.