RE: [PATCH 00/11] pragma once: treewide conversion

From: David Laight
Date: Fri Mar 05 2021 - 04:20:39 EST


From: Linus Torvalds
> Sent: 04 March 2021 20:16
>
> On Thu, Mar 4, 2021 at 5:55 AM David Laight <David.Laight@xxxxxxxxxx> wrote:
> >
> > > (a) the traditional include guard optimization HAS NO HIDDEN SEMANTIC
> > > MEANING. It's a pure optimization that doesn't actually change
> > > anything else. If you don't do the optimization, absolutely nothing
> > > changes.
> >
> > And if the parser is well written the optimisation is probably
> > irrelevant compared to the compile time.
>
> That's actually surprisingly not even remotely true.

The point is that you can skip the unwanted parts of
#if without having to parse the file at all.
You just need to detect the line breaks.

So yes, you need to read the file and look at every byte.
But you don't need to even start tokenising it.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)