by Veedrac · 9y ago · 0 comments
I am finding it extremely hard to envision a circumstance where this is a bottleneck for anything. Care to clarify the context?
I also find the struct layout really odd; why not just move c?
Your benchmarks are also probably broken; branch predictors use global state so will almost certainly predict fine the way you've used things. You need to repopulate a significantly-sized array each time with randomly chosen values. You can't use the same array because it'll be learnt, and you can't use a short array because it'll be predicted globally.
For some additional context, these structs are packed wire-line protocol structs. In reality the padding bytes are full of other fun details.
But, you are right that it probably doesn't matter. The minimal benchmarking I did convinced us that there wouldn't be much of a cost. The code that actually ended up being committed to our project has the branch.