[ktexteditor] much faster positionFromCursor
Summary:
Use mutable variables to store information about last call to positionFromCursor.
As most of the time the cursor is close to the previous position, avoid to calculate every time the size of the lines from the beginning of the document, just calculate it from the previous cursor position.
Test Plan:
Open a callgrind log file with more than 1.00.000 lines,
go to the end of the file, and then play with the PageUp, PageDown and cursor keys.
Before: it was unable to do continuous PageUp refreshes.
After: the PageUp at any part of the file is as fast as in the beginning of the document.
Reviewers: Kate, cullmann, Frameworks
Reviewed By: Kate, cullmann
Subscribers: anthonyfieroni, mwolff, brauch, cullmann, Frameworks
Tags: Kate, Frameworks
Differential Revision: https://phabricator.kde.org/D12016