Skip to content

Optimize minimap drawing

Waqar Ahmed requested to merge work/minimap-optimize into master

Minimap for me gets very slow with large documents (e.g., kateviewhelpers.cpp). Since I run everything with asan some slowdown is expected but in this case it became unbearably slow i.e., visible lags of 200+ ms on scroll and typing.

The summary of optimizations is:

  • Reduce allocations as much as possible
  • Reduce copying
  • Reduce some function calls
  • Use drawPoints api instead of drawing each point separately

Allocations are reduced by introducing a new internal api to get line decorations. This api takes an out vector by ref so that we don't allocate from scratch all the time.

Copies of shared pointers i.e., KTextEditor::Attribute are reduced by modifying public api to return the attribute by ref. Not sure why this wasn't being done as it seems like a sane thing to do.

Overall its more than 3x faster now.

Merge request reports