Does the Java compiler remove multiplications by 1, when talking about BigDecimal?
I'm standing in something similar to this:
BigDecimal bd = getBigDecimal();//get arbitrary bigDecimal, could be anyone.
bd = bd.multiply(new BigDecimal(getOneTwoOrThree());
Where the getOneTwoOrThree method is declared as:
/*
* Always returns Integers 1, 2 or 3.
*/
Integer getOneTwoOrThree(){
//some code
}
So, basically.
if getOneTwoOrThree()
returns 1, will the compiler perform the multiplication? Or will it nop the instruction?
This is somewhat of an existential doubt, but I guess that I'm at some level early - optimizing.