Efficent code writting

As a professional programmer for 30 years, I had a standard response when a programmer asked me about performance differences in code like this. Even on slow, early IBM PC's, you could drag out an ellipse and rubber band its drawing on a graphical display. If you've ever done the math for calculating the pixels in an ellipse you quickly realize that even a slow PC can do an amazing amount of work in very short periods of time.

In your case, I think you'd be hard pressed to actually measure any difference. At worst, you're probably looking at a couple of instructions.

A bigger issue is readability and maintainability. In I code reviewed, I almost always red flagged code that mixed logic in a single if statement. This may sound like an extreme and unnecessary rule but in practice it keeps code very readable and minimizes the possibility of breaking it with future modifications. When you mix logic, you require the reader to do the logic operation in their head. If you actually structure the code to reflect the logic, it's much easier to follow and it's much safer when future changes are necessary.

An alternative approach is to do separate logic into temporary variables. For example,

boolean conditionA = a == 1 and b==3;
boolean conditionB = x == 3 and y == 5;

if (conditionA || condition B) {
...

With good choice of variable names and the separation of logic, you end up with code that is much more readable and robust.

The effect on speed was negligible but there was a huge gain in robustness of the code.