This is the mail archive of the
mailing list for the GCC project.
Re: cpplib: reusing cached include files
- From: Per Bothner <per at bothner dot com>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Neil Booth <neil at daikokuya dot co dot uk>
- Date: Wed, 21 May 2003 12:49:02 -0700
- Subject: Re: cpplib: reusing cached include files
- References: <3ECBCA38.email@example.com><firstname.lastname@example.org>
Zack Weinberg wrote:
What we want to do is cache the results of _cpp_clean_line, not the
Yes. The problem is the _cpp_clean_line cleans the raw buffer
in-place, possibly shortening each line. If we try then re-read
the buffer, there is left-over duplicate crud between the end of
the cleaned line, and the original raw line. My patch overwrites
this crud with whitespace to avoid confusion.
What we could do is append the new cleaned line to the end of
the previous cleaned line, but we don't do that. I suspect the
current behavior is better for memory caches. We could also
maintain a data structure mapping the start of each cleaned line,
but that seems over-kill.
I think something like my patch (but so it doesn't confuse
line numbering) is simple and efficient. A further optimization
would be to disable redundant cleaning when re-using a buffer.
A simple way to do that is to add a 'cleaned' flag to each buffer.