There are situations where we can store values in local variables and work with them. For example:
String data;
int a, b;
data = Integer.toHexString(memory.read(PC));
a = ("00" + data).substring(data.length());
data = Integer.toHexString(memory.read(PC + 1));
b = ("00" + data).substring(data.length());
Or we can just make multiple function calls to achieve the same thing:
a = ("00" + Integer.toHexString(memory.read(PC))).substring(Integer.toHexString(memory.read(PC)).length());
b = ("00" + Integer.toHexString(memory.read(PC + 1))).substring(Integer.toHexString(memory.read(PC + 1)).length());
Which one is better from the performance point of view?
memory.read(...)
. Give the variables names that explain the nature or the purpose of that information. – Solomon Slow Oct 06 '17 at 13:55memory.read
could return different values for the same inputs over time, these would not be equivalent implementations. – Joe Oct 11 '17 at 00:50