<table><tr><td style="">sars 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/D14408">View Revision</a></tr></table><br /><div><div><p>It definitely does <strong>not</strong> mean "The CPU waste does not matter".</p>

<p>I actually tried adding the timer to the function to measure the time. I tried it on a almost 4000 lines long C++ file (far too big ;) and it has around 200 symbols. In the measurements I did, it never reached a full millisecond to finish, it always printed 0ms.</p>

<p>I'm just saying that I don't think the complexity added for the micro-optimization is worth it. It just becomes harder to maintain. The possible gain of <strong>less</strong> than 1ms in the situation when the user presses a key or releases the key, just does not change the perception of how fast or slow the application reacts.</p>

<p>Making the delay longer (200 ms) does not decrease the number of times the function is called. It still stays at once when the key is pressed and once when the key is released. <br />
The bad thing is that the user actually feels that the plugin is slower as it now takes 200ms for the current-item to change in stead of just 100ms previously.</p>

<p>That said I think stopping the m_currItemTimer on document change and not starting it if m_updateTimer is active, is a real noticeable improvement. Especially when adding new lines just above a symbol.</p>

<p>One thing that you could cache without much complexity is the last cursor position and only start the timer if the line changes.</p>

<p>Regards,</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);">Kåre</pre></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R40 Kate</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D14408">https://phabricator.kde.org/D14408</a></div></div><br /><div><strong>To: </strong>loh.tar, Kate, sars<br /><strong>Cc: </strong>sars, kwrite-devel, Kate, michaelh, kevinapavew, ngraham, demsking, cullmann, dhaumann<br /></div>