In terms of number of operations, compiling time and good practices, is there any difference by doing
for(int i = 0; i < x.size(); i++)
instead of
int size = x.size();
for(int i = 0; i < size; i++)
If there were no compiling optimization I'd say the latter would be preferable, because it is not calling the function stack every time, it assigns one time a variable and then accesses it instead of calling a function.
Does compiling optimization handle this underneath? Let's say I wanted to optimize the code to the most computationally economic as possible; would it be any different?