perf(column): keep track of number of lines that hold up the 'signcolumn'

Problem:  The entire marktree needs to be traversed each time a sign is
          removed from the sentinel line.
Solution: Remove sentinel line and instead keep track of the number of
          lines that hold up the 'signcolumn' in "max_count". Adjust this
          number for added/removed signs, and set it to 0 when the
          maximum number of signs on a line changes. Only when
          "max_count" is decremented to 0 due to sign removal do we need
          to check the entire buffer.

          Also replace "invalid_top" and "invalid_bot" with a map of
          invalid ranges, further reducing the number of lines to be
          checked.

          Also improve tree traversal when counting the number of signs.
          Instead of looping over the to be checked range and counting
          the overlap for each row, keep track of the overlap in an
          array and add this to the count.
This commit is contained in:
Luuk van Baal
2023-12-06 13:34:19 +01:00
committed by Lewis Russell
parent e42f03264b
commit 4a34da82c1
14 changed files with 201 additions and 173 deletions

View File

@@ -703,11 +703,10 @@ struct file_buffer {
// may use a different synblock_T.
struct {
int size; // last calculated number of sign columns
int max; // maximum value size is valid for.
linenr_T sentinel; // a line number which is holding up the signcolumn
linenr_T invalid_top; // first invalid line number that needs to be checked
linenr_T invalid_bot; // last invalid line number that needs to be checked
int max; // maximum number of signs on a single line
int max_count; // number of lines with max number of signs
bool resized; // whether max changed at start of redraw
Map(int, SignRange) invalid[1]; // map of invalid ranges to be checked
} b_signcols;
Terminal *terminal; // Terminal instance associated with the buffer