vendredi 13 avril 2018

ENUM usage in conditional expressions in Java

I have a simple java if condition with a boolean comparison and a Enum comparison.

if(testBoolean && testEnumObj != TestEnum.Test) {
 //TO DO:
}

I got a suggestion from my supervisor to split this into two if blocks for performance reasons. I wanted to confirm whether the above expression will have an impact in the performance or memory occupancy instead of having two if block as below.

if(testBoolean) {
   if(testEnumObj != TestEnum.Test) {
     // TO DO:
   }
}

I am not seeing any performance improvement in splitting the first expression into second. Just wanted to confirm to support my argument with my reviewer. Please do the needful.

Aucun commentaire:

Enregistrer un commentaire