Toggy, most replies to this topic have been sarcastic, and from your most recent replies, it appears you do not understand the topic. So here is a serious reply for you:
Before compiling your program and releasing the exe turn everything to one line. |
This will make zero difference. C++ is compiled, so all that text is parsed by the compiler and converted to binary code. Adding or removing whitespace does not result in any difference in the generated program... so making everything 1 line does absolutely nothing but waste your time.
In order to speed up your program, you will need to change what binary code is generated -- this means actual logic changes, not just changing how the code looks.
Remove all comments from your program (not much of a performance boost but enough to notice). |
Again.. C++ is compiled, so all comments will be discarded by the compiler anyway, and will not exist in the binary. So manually removing comments is pointless and wastes your time.
Avoid making tons of cpp files. Try to make one cpp file. (very big performance boost). |
This might have some impact, but not in the way you think. Individual C++ files will be compiled separately and then "linked" together to form the final executable. Moving all the code into one cpp file might change how the linker generates the executable, but not in any significant way. Certainly not enough to make a noticeable performance difference.
In general... C++ is fast. And you don't need to worry about "speeding it up" unless your program is noticeably slow. (What's the point in making your program run 1 ns faster when it already runs virtually instantaneously?)
When you
do need to optimize your program... no quick fix like this is going to do it. Usually it involves big algorithm and logic changes. IE: ripping apart portions of your code and rewriting them to be faster.
Adding/removing whitespace or comments... shortening variable names... reducing the number of cpp files... etc... none of that matters. At best those will change compile time (note that having one big cpp file will actually make compile time significantly slower)... but the final program will be the same.
So yeah... long story short: don't worry about optimization. When you know enough C++ to understand how to do it right, you'll understand why it usually isn't necessary.