I'm fairly new to Java and I'm writing an android game - and there's one line of code in a tight loop that's really annoying me.
targetBlocksRemain += letterArray[column][row].isTargetBlock() ? 1 : 0;
I feel like must be possible to write this without the conditional statement and therefore without the potential branch prediction performance hit.
I'll optimise out the tight loop eventually so I'm not massively concerned in the long run, but it'd be nice to know if there's a way to resolve similar situations.
edit Just to clarify - this is a pseudo theoretical questions - there are lots of other things I could do to improve this, such as store isTargetBlock as an int. I'm not really interested in other suggestions, just wondering if there's a way do resolve this particular issue.
edit 2 Hoping to look at what the Dalvik VM is doing shortly to work out how it handles this.