The compiler will see that var3 is just two numbers added together and replace it with 7, which saves having to do an addition every time you run through that code, and is therefore faster. var1 and var2 may be removed from the output as well; shorter code runs faster since you can fit more in the cache. In fact, since var3 is just a number, you can replace every place that it's used with a 7 as well; if you have some functions:
// be careful! if the number of apples is less than six then the UI will not line up properly
auto getTheNumberOfApples() -> int {
auto jackApples = 3;
auto jillApplies = 4;
return jackApples + jillApplies;
}
auto appleWeight() -> float {
return 0.2 * getTheNumberOfApples();
}
... then the compiler will look at all that, delete the lot, and just use 1.4f wherever the appleWeight() function was called. Comment is gone, the decision making is gone, it's impossible to go backwards any more.