This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cpplib: reusing cached include files


Zack Weinberg wrote:

What we want to do is cache the results of _cpp_clean_line, not the
raw buffers.

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.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]