I know that computers these days are rather fast and low efficiency tweaks, such as I’m about to ask, don’t really have that much importance, but I think it’s still good to know.
int something;
something = 5;
or
int something = 5;
If the compiler compiles the two pieces of code differently then which of the two above pieces of code is more efficient. It will probably differ from compiler to compiler but I’m mainly interested in gcc.
In these days, when you turn on optimizations, you (pretty much) can’t predict ANYTHING about the generated code. Believe it or not, your code is describing the ends, not the means! So it doesn’t make much sense to predict how it’ll execute, especially after optimizations — all that C guarantees is that it’ll give you the result you asked for.
And before optimizations, it doesn’t make sense to worry about it.
And your code is trivial for the compiler to optimize, so don’t worry about it.
Start thinking about more important things in your program. 🙂