On 04/08/2010 00:51, Jean-Marc Lasgouttes wrote:

The spellchecker finally decided to work for a reason I do not understand :)
I can indeed check that it becomes
very slow and Shqrk.qpp tells me that all the time is spent in
checkSpellingOfString ;(

What could we do from there?

The first solution is to make Paragraph send strings directly to the
spellchecker. This would
require to rework the spellcheck interface to allow to pass full strings. I
do not think
that aspell or enchant allow this, although I could not find a documentation
for enchant :(


The interface can be changed to pass words, sentences or paragraph. Then the
implementation will tell the Paragraph which method to use.


The problem with this approach is that I am not even sure that it will be
enough. I am not sure
whether the time is spent in the setup of the function or in the word
checking itself. r

If checking is slow (bad apple!), then we would have to rethink the
on-the-fly checking strategy.

Abdel, in case you are here:


Briefly today...

 what were the other strategies, and which ones were doable and would
incur less calls to the spellchecker?


In my first version, each paragraph maintained its own list of misspelled
words. The check was done whenever the cursor was edited for the whole
paragraph. Which means that other paragraphs where not ckecked.

My second version (ab)used the completion framework. It was working fast but
revealead to be complicated to extend for second pass. Again, here only the
edited paragraph was checked.

Then, as I found that the on screen check was very fast for both aspell and
hunspell under Linux and Windows, I didn't bother improving the second
version. Note here that the check is triggered only by row metrics changes
(which doesn't happen very often). But there are still room for improvement:
caching, etc.
Note that this last method offers the best user experience because all
visible paragraphs are checked, much better in fact than OpenOffice,
MSOffice or Thunderbird.
While I am writing this I am thinking that maybe there are (again!) some
metrics and painting bugs that cause full redraw instead of single row
redraw in Mac? That would explain in part the additional slowness while
writing.



Anyway, the fact is that I did the checks by pressing page down repeatedly
on a big manual, which
means that the number of words that got checked cannot be made smaller than
they are now :(

While typing this, I notice that Mail.app only does on the fly checking at
cursor position.


So that's a confirmation that even Mail.app developpers found the
spellchecker to be slow.

 I could add a
"isSlow()" method to the spell checking backends and revert to this strategy
for slow backends...


Well, we can of course do better by caching the correctly spelled and the
mispelled words within the spellchecker interface. This will requires some
memory but this will improve the speed dramatically because of the reduced
calls to the native Mac checker. A bit like what we do for gettext
optimisation.

Abdel.

Reply via email to