<table><tr><td style="">jtamate updated this revision to Diff 31853.<br />jtamate marked 5 inline comments as done.<br />jtamate added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D12016">View Revision</a></tr></table><br /><div><div><p>Included more comments.<br />
Addressed style coding.</p>
<p>In a callgrind log file with 1606189 lines, at the end of the file, pressing PageUp, using the code included at the end:</p>
<p>old implementation elapsed = 122<br />
new implementation elapsed = 0<br />
old implementation elapsed = 119<br />
new implementation elapsed = 0</p>
<p>After some insertions:<br />
old implementation elapsed = 137<br />
new implementation elapsed = 118<br />
old implementation elapsed = 123<br />
new implementation elapsed = 0</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">src/view/kateviewaccessible.h</li>
</ul>
<p>+++ src/view/kateviewaccessible.h<br />
@@ -29,6 +29,8 @@<br />
#include <QAccessible><br />
#include <KLocalizedString><br />
#include <QAccessibleWidget><br />
+#include <QElapsedTimer><br />
+#include <QDebug></p>
<p>/**</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">This class implements a QAccessible-interface for a KateViewInternal.</li>
</ul>
<p>@@ -194,6 +196,9 @@ public:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);"> */
int positionFromCursor(KateViewInternal *view, const KTextEditor::Cursor &cursor) const
{</pre></div>
<p>+ QElapsedTimer t;<br />
+ t.start();<br />
+</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">int pos = m_lastPosition;
const auto *doc = view->view()->document();</pre></div>
<p>@@ -229,6 +234,22 @@ public:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">m_lastCursor = cursor;
m_lastPosition = pos;</pre></div>
<p>+ qWarning() << "new implementation elapsed = " << t.restart();<br />
+ <em> previous implementation<br />
+ int _pos = 0;<br />
+ for (int _line = 0; _line < cursor.line(); ++_line) {<br />
+ </em> length of the line plus newline<br />
+ _pos += view->view()->document()->line(_line).size() + 1;<br />
+ }<br />
+ _pos += cursor.column();<br />
+ qWarning() << "old implementation elapsed = " << t.elapsed();<br />
+<br />
+ return pos;<br />
+ if (_pos != (pos + cursor.column())) {<br />
+ qWarning() << "implementations differ, old=" << _pos << " new=" <<<br />
+pos + cursor.column();<br />
+ }<br />
+</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);"> return pos + cursor.column();
}</pre></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R39 KTextEditor</div></div></div><br /><div><strong>CHANGES SINCE LAST UPDATE</strong><div><a href="https://phabricator.kde.org/D12016?vs=31760&id=31853">https://phabricator.kde.org/D12016?vs=31760&id=31853</a></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D12016">https://phabricator.kde.org/D12016</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/view/kateviewaccessible.h<br />
src/view/kateviewinternal.cpp</div></div></div><br /><div><strong>To: </strong>jtamate, Kate, cullmann, Frameworks<br /><strong>Cc: </strong>mwolff, brauch, cullmann, Frameworks, michaelh, kevinapavew, ngraham, bruns, demsking, sars, dhaumann<br /></div>