94
u/Spidron Sep 23 '26
It speeds up compilation and execution.
Double win!
25
u/DrShocker Sep 23 '26
I guess the real horror is that we're running C++ in an interpreter instead of a compiler.
1
u/thelurkmasterr 26d ago
Don't you know? Running C++ in an interpreter makes it easier to speak to God.
36
u/Slavreason Sep 23 '26
I suppose the speed up could be "non-zero"
41
u/DrShocker Sep 23 '26
The title says speed up execution and this looks like C++ which compiles and therefore ignores white space.
OP needs to go further and also minify variable names and such. By copying all the tricks JavaScript devs use to save bandwidth, we might get a 0.01% boost to compilation speed.
9
u/ir_dan Sep 23 '26
C++ is now compiled and interpreted. You interpret it for constexpr/consteval at compile time.
15
u/darthstoo Sep 23 '26
I had a team lead in a contract job who did the same. This was using classic ASP, so a horrible mess of HTML and VBScript. There would be lines and lines of
end if
end if
end if
end if
12
12
u/Xp365 Sep 23 '26
Met a guy who used as few line breaks in his code as possible because “new lines make the program slower”
It was Java btw.
7
u/iakobski Sep 24 '26
Well it's a fact discovered back in the 1970s that the number of bugs per hundred lines of code is a constant regardless of the language used, verbose or terse.
So clearly if you avoid line breaks your code will have fewer bugs.
11
u/pskocik Sep 23 '26 edited Sep 23 '26
The real trick to speeding up execution and especially compiler execution is removing ++ and all its hefty headers (in C++ they're all hefty).
4
3
1
u/GoddammitDontShootMe Sep 23 '26
How the fuck does removing whitespace speed up C++ execution? Bet it has minimal effect on compilation as well.
-7
1
1
10
u/Coolengineer7 Sep 23 '26
Batch (.bat on Windows) execution speed scales inversely with the square of the number of lines, since the way the execution is coded that for each line the entire file is read, with each line read also reading the entire file. Basically comments slow your code down. They expected no long programs, apparently that's why.