mwolff added a comment.
Also, what is "@mwolf solution" - I didn't provide any code, until now: diff --git a/src/spellcheck/spellcheck.cpp b/src/spellcheck/spellcheck.cpp index 9e04d788..3a97e5c5 100644 --- a/src/spellcheck/spellcheck.cpp +++ b/src/spellcheck/spellcheck.cpp @@ -170,10 +170,32 @@ QList<QPair<KTextEditor::Range, QString> > KateSpellCheckManager::spellCheckWrtH if (!kateTextLine) { continue; // bug #303496 } + const auto attributes = kateTextLine->attributesList(); + auto attributes_it = attributes.begin(); + const auto attributes_end = attributes.end(); + auto find_attr = [&attributes_it, attributes_end](int pos) -> int { + // bail out early if possible + if (attributes_it == attributes_end || attributes_it->offset > pos) { + return 0; + } + // advance until we encompass the position + while (pos >= (attributes_it->offset + attributes_it->length)) { + ++attributes_it; + if (attributes_it == attributes_end) { + return 0; + } + } + // now check if we have a match + if (attributes_it->offset <= pos) { + return attributes_it->attributeValue; + } else { + return 0; + } + }; 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! - int attr = kateTextLine->attribute(i); + int attr = find_attr(i); const KatePrefixStore &prefixStore = highlighting->getCharacterEncodingsPrefixStore(attr); QString prefixFound = prefixStore.findPrefix(kateTextLine, i); if (!document->highlight()->attributeRequiresSpellchecking(static_cast<unsigned int>(attr)) 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 `QElapsedTimer` 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. 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 `TextLineData`. REPOSITORY R39 KTextEditor REVISION DETAIL https://phabricator.kde.org/D11487 To: jtamate, #frameworks, #kate Cc: anthonyfieroni, dhaumann, mwolff, cullmann, michaelh, kevinapavew, ngraham, demsking, sars