Consider the following two code examples:
Example 1.
public void setValue(int value)
{
mValue = value;
}
Example 2.
public void setValue(int value)
{
if (mValue != value)
{
mValue = value;
}
}
Pretend you've been tasked to optimise some Java code to the absolute max, beyond all common sense.
Would the second code example be an optimisation of the first? By that I mean, is there any difference (no matter how miniscule) between an if condition check and an int assignment at the lowest levels of Java or the JVM?