Optimize rendering spaces with dyn wrapping
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:
- Collect all spaces in the line by iterating over the text in reverse
- 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.
- Render all the collected space points at once.