-
- Downloads
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.
Loading
Please register or sign in to comment