Which one is faster?
Assume an average compiler for C++.
///////////////////////
Code A:
int a,b,c;
///////////////////////
Code B:
int a;
int b;
int c;
///////////////////////
It is also said that the compiler ignores comments completely. Like-
"// Comment"
OR
/* Comment*/
Assume your program has a comment block of a million lines. I'm sure the compiler reads for " / * " first and searches for the " * / " and identifies all the text between these two as comments. But doesn't that mean the compiler is iterating through million lines of code to find the " * / " after it encounters the " * / " ??
TLDR;
My questions are:-
- 1) Is Code A faster or Code B??? Does short code mean less compilation time?
- 2) Do comments contribute to compilation time?
- 3) How can I learn to optimize my code for best performance?