<table><tr><td style="">mwolff 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/D11487">View Revision</a></tr></table><br /><div><div><p>Also, what is "<span class="phabricator-remarkup-mention-unknown">@mwolf</span> solution" - I didn't provide any code, until now:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="diff" 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);"><span style="color: #000080">diff --git a/src/spellcheck/spellcheck.cpp b/src/spellcheck/spellcheck.cpp</span>
<span style="color: #000080">index 9e04d788..3a97e5c5 100644</span>
<span style="color: #a00000">--- a/src/spellcheck/spellcheck.cpp</span>
<span style="color: #00a000">+++ b/src/spellcheck/spellcheck.cpp</span>
<span style="color: #800080">@@ -170,10 +170,32 @@ QList<QPair<KTextEditor::Range, QString> > KateSpellCheckManager::spellCheckWrtH</span>
if (!kateTextLine) {
continue; // bug #303496
}
<span style="color: #00a000">+ const auto attributes = kateTextLine->attributesList();</span>
<span style="color: #00a000">+ auto attributes_it = attributes.begin();</span>
<span style="color: #00a000">+ const auto attributes_end = attributes.end();</span>
<span style="color: #00a000">+ auto find_attr = [&attributes_it, attributes_end](int pos) -> int {</span>
<span style="color: #00a000">+ // bail out early if possible</span>
<span style="color: #00a000">+ if (attributes_it == attributes_end || attributes_it->offset > pos) {</span>
<span style="color: #00a000">+ return 0;</span>
<span style="color: #00a000">+ }</span>
<span style="color: #00a000">+ // advance until we encompass the position</span>
<span style="color: #00a000">+ while (pos >= (attributes_it->offset + attributes_it->length)) {</span>
<span style="color: #00a000">+ ++attributes_it;</span>
<span style="color: #00a000">+ if (attributes_it == attributes_end) {</span>
<span style="color: #00a000">+ return 0;</span>
<span style="color: #00a000">+ }</span>
<span style="color: #00a000">+ }</span>
<span style="color: #00a000">+ // now check if we have a match</span>
<span style="color: #00a000">+ if (attributes_it->offset <= pos) {</span>
<span style="color: #00a000">+ return attributes_it->attributeValue;</span>
<span style="color: #00a000">+ } else {</span>
<span style="color: #00a000">+ return 0;</span>
<span style="color: #00a000">+ }</span>
<span style="color: #00a000">+ };</span>
const int start = (line == startLine) ? startColumn : 0;
const int end = (line == endLine) ? endColumn : kateTextLine->length();
for (int i = start; i < end;) { // WARNING: 'i' has to be incremented manually!
<span style="color: #a00000">- int attr = kateTextLine->attribute(i);</span>
<span style="color: #00a000">+ int attr = find_attr(i);</span>
const KatePrefixStore &prefixStore = highlighting->getCharacterEncodingsPrefixStore(attr);
QString prefixFound = prefixStore.findPrefix(kateTextLine, i);
if (!document->highlight()->attributeRequiresSpellchecking(static_cast<unsigned int>(attr))</pre></div>
<p>Can you try that locally and see how it goes for you? Without a way to reproduce, I can't say how it performance as it's fast before and after for me :) With some <tt style="background: #ebebeb; font-size: 13px;">QElapsedTimer</tt> directly in this method, I see that the above is faster than the previous method, but it drowns in the overall measurements. Anyhow, this should in theory be better than any binary search as it will only go through the list at most once per line, whereas the binary search has to find the start position repeatedly.</p>
<p>But as I said, both approaches could be combined if we want to. And of course if we decide to follow my suggestion, then I'd need to clean it up to put the code directly into <tt style="background: #ebebeb; font-size: 13px;">TextLineData</tt>.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R39 KTextEditor</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D11487">https://phabricator.kde.org/D11487</a></div></div><br /><div><strong>To: </strong>jtamate, Frameworks, Kate<br /><strong>Cc: </strong>anthonyfieroni, dhaumann, mwolff, cullmann, michaelh, kevinapavew, ngraham, demsking, sars<br /></div>