While looking at a micro-optimization question that I asked yesterday (here), I found something strange: an or
statement in Java is running slightly faste
Loading some random piece of data is generally slower than a little non-branching code.
It all depends upon processor architecture, of course. Your first if statement could be implemented as four instructions. The second may potentially need null pointer checking, bounds checking as well as the load and compare. Also more code means more compile time, and more chance for the optimisation to be impeeded in some manner.