Skip to content

Optimize rendering spaces with dyn wrapping

Waqar Ahmed requested to merge work/faster-spaces into master

When dynamic wrapping is enabled and a QTextLine has trailing spaces, then those spaces aren't really shown unless QTextOption::ShowTabsAndSpaces is enabled. Thus we shouldn't waste time rendering spaces at the same position.

With this commit, rendering of spaces is split into 3 steps:

  1. Collect all spaces in the line by iterating over the text in reverse
  2. Iterate over all the collected spaces in reverse because we want to look at the spaces in the beginning of line first and convert each space position into a QPointF. Whenever we encounter a point which was equal to the last collected point, we stop the loop and break.
  3. Render all the collected space points at once.

BUG: 465841

Merge request reports