A way to significantly speed up compiles?
Michael Meissner
meissner at osf.org
Thu Dec 27 07:14:47 AEST 1990
In article <1037 at gistdev.gist.com> flint at gistdev.gist.com (Flint
Pellett) writes:
| This is a proposal on how to make C compiles a lot faster, but it may
| not be a useful enough case to be worth it for typical C programs.
| I thought I'd throw the idea up for discussion though. Consider the
| following sample of code:
|
| #define STARTLOC 0
| <..10 things..>
| #define ENTRY1 STARTLOC + 10
| <..5 things..>
| #define ENTRY2 ENTRY1 + 5
| <..7 things..>
| #define ENTRY3 ENTRY2 + 7
| ...
| int pointers[] = {STARTLOC,ENTRY1,ENTRY2,ENTRY3...
|
| I expected the output of cpp to look like this:
|
| int pointers[] = {0 , 10 , 15 , 22 , ...
|
| cpp, however, is only doing simple text substitution here, and produced:
|
| int pointers[] = {0 , 0+10 , 0+10+5 , 0+10+5+7 , ...
|
| If you're trying to use MSC5.1 it doesn't even work: after you get
| somewhere around ENTRY60, it quits, telling you you've tried to nest
| your constants too deeply. The questions is, why not have cpp combine
| those numbers at pre-processor time? Wouldn't it make a lot more
| sense to have cpp add 0+10+5+7 together once when ENTRY3 is #defined
| in cpp rather than making the compiler add those numbers together 100
| times in the 100 places that ENTRY3 is used?
Why not use an enumeration instead of lots of defines (unless of
course you have a PCC-derived compiler and more than 150 defines)?
This 'optimization' will buy you so little, I doubt you could measure
it. In fact, I would suspect that it will actually slow things down
(making the preprocessing MUCH more complex in order to shave a few
milliseconds off of the compiler proper).
--
Michael Meissner email: meissner at osf.org phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
Considering the flames and intolerance, shouldn't USENET be spelled ABUSENET?
More information about the Comp.lang.c
mailing list