0

Let me state something. I don't need the performance but I was wondering if a file like this:

#include<stdio.h>
int main(void){printf("Hello, world!");}

gets compiled faster than this

#include <stdio.h>
int main(vod)
{
    printf("Hello, world!");
}

because the compiler doesn't have to skip as much newlines and whitespaces as in the other text.

Notiq
  • 21
  • 11
  • 1
    That's a resounding **no** – bolov Feb 09 '23 at 18:15
  • 2
    No. But I'm old enough to remember when people tried it, and also to save disk space. Back in 1979 I worked on a COBOL program for NCR which had all spaces and newlines removed. Complete nightmare. – john elemans Feb 09 '23 at 18:17
  • 1
    This might be an interesting read for you: [Wikipedia: Compiler Contruction](https://en.wikipedia.org/wiki/Compiler#Compiler_construction) – SiKing Feb 09 '23 at 18:22
  • 3
    You're unlikely to be able to measure the difference. However, if you start each line with a thousand spaces, it will take (a very little) longer to process than a file without so many spaces, simply because the file size is smaller. The performance difference will be extremely hard to measure because a compiler does so much else as well. – Jonathan Leffler Feb 09 '23 at 19:02
  • 1
    Have you tried measuring the difference? – Jonathan Leffler Feb 09 '23 at 19:03
  • 1
    Text parsing is a very tiny fraction of the total time, especially for modern optimizing compilers. Even with optimization disabled it's trivial. See [Disable all optimization options in GCC](https://stackoverflow.com/a/33284629) / [Why are there so few C compilers?](https://softwareengineering.stackexchange.com/q/273698) – Peter Cordes Feb 09 '23 at 21:34

0 Answers0