Skip to content
Snippets Groups Projects
Commit 66af77cb authored by Andi Kleen's avatar Andi Kleen
Browse files

Add a cache of recent lines

For larger files the file_cache line index will be spread out to make
the index fit into the fixed buffer, so any access to the non latest line
will need some skipping of lines.

Most accesses for line are near the latest line because
a diagnostic is likely near where the scanner is currently lexing.

Add a second cache for recent lines. It is organized as a ring buffer
and maintains the last 256 lines relative to the last input line.

With that, enabling -Wmisleading-indentation for the test case in
PR preprocessor/118168, is within the run-to-run variation.

gcc/ChangeLog:

	PR preprocessor/118168
	* input.cc (file_cache::m_line_recent,
	m_line_recent_first, m_line_recent_last): Add.
	(file_cache_slot::evict): Clear new fields.
	(file_cache_slot::create): Clear new fields.
	(file_cache_slot::file_cache_slot): Initialize new fields.
	(file_cache_slot::~file_cache_slot): Release m_line_recent.
	(file_cache_slot::get_next_line): Maintain ring buffer of lines
	in m_line_recent.
	(file_cache_slot::read_line_num): Use m_line_recent to look up
	recent lines quickly.
parent 0b6453d5
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment