Why are character arrays special (e
Walter Bright
bright at Data-IO.COM
Thu Feb 16 07:36:16 AEST 1989
In article <1989Feb14.161906.16138 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>In article <1875 at dataio.Data-IO.COM> bright at dataio.Data-IO.COM (Walter Bright) writes:
>A compiler that spends most of its time tokenizing source obviously isn't
>working very hard at code generation.
The optimizer is a separate pass, it's designed that way so the user has the
choice of fastcompile/slowexecute or slowcompile/fastexecute.
BTW, my code generator is very efficient (it's not table driven, it's all
ad-hoc inline stuff, and is heavily optimized).
>>... I've found in my compiler (Zortech) that ONE extra
>>instruction executed per char read slows down the compiler by 5 to 10%.
>Hmm, that's 10-20 instructions per character, with C typically about
>20 chars/line, and with even a decidedly slow machine delivering an
>instruction per microsecond, gives us 2500+ lines/second.
I tested it on my own code, which includes lots of comments, macro defs
and extern defs (all the .h files). Most of the identifiers are
relatively long. The number of lines in the .h files dwarf the number
of lines in the .c files. None of this stuff goes through the
code generator, so my results are different from that of code which
consists mosly of expressions. The ideal is to get the speed of processing
white space, comments, and false conditionals to approximate the speed
of simply reading characters from a file.
>If it's that big a deal, have you considered having a default "no trigraphs"
>mode and a slower "trigraphs" mode? That way, if nobody uses it, there's
>no impact except for a bit of code that never gets executed.
That's the way I decided to implement it. The main difficulty, however, with
this approach is that magazine C compiler reviewers frequently don't read
the manual, and may simply run the compiler with the default settings, and
wrongly conclude that it doesn't support trigraphs. For example, the
latest BYTE review feature list for Zortech C contains numerous errors, all
resulting from the reviewers not reading the manual.
More information about the Comp.lang.c
mailing list