Colin Rafferty writes:
I think that this is a false optimization. The only time that code
is
correctly optimizing is if we are searching for the beginning of a
comment that has no beginning. Otherwise, it does nothing except
cause bugs.
I'm not arguing that the optimization is correct all the time.
It's only works if you play by a certain set of rules,
understanding the limitations.
Without saved state, it is impossible to tell whether you're inside
or outside a comment without starting from the beginning of the
buffer, sweeping through the buffer and watching what comment and
string delimiters go by. This is hellishly expensive. So, to
speed parsing, it was decided that if you see something that would
be a defun were it outside a comment or string, you assume that it
_is_ outside a comment or string. The assumption is correct most
of the time, and that's good enough unless you're using font-lock on
a medical display. "Ooops, all those green life-sign indicators
should be red! He's dead, Jim."