D12016: [ktexteditor] much faster positionFromCursor
Milian Wolff
noreply at phabricator.kde.org
Tue Apr 10 20:13:14 UTC 2018
mwolff added a comment.
some nits, otherwise lgtm assuming all tests pass
bonus points for a proper benchmark that shows the before/after gain in hard numbers
INLINE COMMENTS
> kateviewaccessible.h:191
> {
> - int pos = 0;
> - for (int line = 0; line < cursor.line(); ++line) {
> - // length of the line plus newline
> - pos += view->view()->document()->line(line).size() + 1;
> + int pos = m_lastPosition;
> + const KTextEditor::Document *doc = view->view()->document();
I know the old code used int already, but shouldn't this better be a quint64 as it's a file offset?
> kateviewaccessible.h:192
> + int pos = m_lastPosition;
> + const KTextEditor::Document *doc = view->view()->document();
> +
const auto *doc =
> kateviewaccessible.h:204
> + m_lastView = view;
> }
> + else {
style: join with next line
> kateviewaccessible.h:215
> + pos += cursor.line() - m_lastCursor.line();
> + }
> + else {
dito
> kateviewaccessible.h:231
> private:
> +
> inline KateViewInternal *view() const
unrelated change?
> kateviewaccessible.h:270
> + mutable KTextEditor::Cursor m_lastCursor;
> + // m_lastPosition stores the positionFromCursor, with the cursor always in column 0
> + mutable int m_lastPosition;
maybe also mention that this is a file offset?
REPOSITORY
R39 KTextEditor
REVISION DETAIL
https://phabricator.kde.org/D12016
To: jtamate, #kate, cullmann, #frameworks
Cc: mwolff, brauch, cullmann, #frameworks, michaelh, kevinapavew, ngraham, bruns, demsking, sars, dhaumann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180410/8fef4f6a/attachment.html>
More information about the Kde-frameworks-devel
mailing list