jtamate added a comment.
> One question to that though: Why do you sort/lookup by `x.offset + x.length <= p`? Note how lower_bound returns the first iterator that is _not_ going to return true. Assuming there are neither overlaps nor unsorted entries. Lets call X the iterator returned by lower_bound, suppose X is not cend(), so X.offset + X.length > p. If other iterator Y could satisfy Y.offset + Y.length > p and Y.offset <= X.offset, it means there are overlaps, contradiction. Therefore, the rest of the iterators has the following properties: Y.offset + Y.length > p and Y.offset > X.offset or Y.offset + Y.length <= p and Y.offset < X.offset > To me, it looks like your code cannot actually work and will always return 0? Nope. Otherwise the tests fail, more precisely kateindenttest. > Personally, I'd try to use `upper_bound` with `x.offset < p` in the comparison. The iterator should then point to the first item that has it's offset larger than `p`. So decrementing the iterator once (while checking against `begin()`) yields the iterator that could potentially match. Thus, check if `p` is contained in its range and if so return it's attribute, otherwise return 0. I've tried. The code gets uglier. > Besides this: I am still looking for an explanation why spell checking is so extremely slow for you. I have the same settings enabled, and spell checking is seemingly fast for me... Am I missing some dictionary or something other to reproduce this? Perhaps some Ignored words? I have Amarok, KAddressBook, KDevelop, KHTML, KIO, .... > Also, what is "@mwolf solution" we can return the iterator and take it as an argument again. I tried locally the python style, returning a QPair. > Can you try that locally and see how it goes for you? I only get one second less, 33 seconds. The problem is that attribute() is called from more places. Is it worth to have two implementations? REPOSITORY R39 KTextEditor REVISION DETAIL https://phabricator.kde.org/D11487 To: jtamate, #frameworks, #kate Cc: anthonyfieroni, dhaumann, mwolff, cullmann, michaelh, kevinapavew, ngraham, demsking, sars