On Tue, Apr 18, 2000 at 10:52:24AM +0200, Jean-Marc Lasgouttes wrote:
> I thought KLyX was using KSpell (KDE spellcheck class), but an
> inspection of the code showed that this is not the case. Inspecting
> the differences in code source may be useful, then.
> 

I've discovered why the spellchecking in LyX is so slow: after each word is
spellchecked, LyX calls to fl_check_forms() to check if the user has pressed
the stop/close button. These calls makes the spellchecking so slow.
I've created a patch that calls to fl_check_forms() only every 1000 words.
The new code is faster by a factor of 50!

I've also looked at KLyX, and the code there is almost identical, but since
the call to fl_check_forms() is replaced by kapp->processEvents(), KLyX
performs better as the latter is more efficient than the former.
Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/ChangeLog,v
retrieving revision 1.285
diff -u -p -r1.285 ChangeLog
--- ChangeLog   2000/04/24 20:58:20     1.285
+++ ChangeLog   2000/04/25 14:26:07
@@ -1,3 +1,8 @@
+2000-04-25  Dekel Tsur  <[EMAIL PROTECTED]>
+
+       * src/spellchecker.C (RunSpellChecker): Speedup spellchecking by
+       a factor of 50!
+
 2000-04-23  Dekel Tsur  <[EMAIL PROTECTED]>
 
        * A lot of files: Added Ascii(ostream &) methods to all inset
Index: src/spellchecker.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/spellchecker.C,v
retrieving revision 1.20
diff -u -p -r1.20 spellchecker.C
--- src/spellchecker.C  2000/04/17 14:00:17     1.20
+++ src/spellchecker.C  2000/04/25 14:26:10
@@ -676,28 +676,29 @@ bool RunSpellChecker(BufferView * bv)
                if(newvalue!= oldval) {
                        oldval = newvalue;
                        fl_set_slider_value(fd_form_spell_check->slider, oldval);
+               }
+
+               if (word_count%1000 == 0) {
+                       obj =  fl_check_forms();
+                       if (obj == fd_form_spell_check->stop) {
+                               delete[] word;
+                               ispell_terminate();
+                               return true;
+                       }
+                       if (obj == fd_form_spell_check->done) {
+                               delete[] word;
+                               ispell_terminate(); 
+                               return false;
+                       }
                }
 
                result = ispell_check_word(word);
                if (isp_pid == -1) {
+                       delete result;
                        delete[] word;
                        break;
                }
 
-               obj =  fl_check_forms();
-               if (obj == fd_form_spell_check->stop) {
-                       delete result;
-                       delete[] word;
-                       ispell_terminate();
-                       return true;
-               }
-               if (obj == fd_form_spell_check->done) {
-                       delete result;
-                       delete[] word;
-                       ispell_terminate(); 
-                       return false;
-               }
-    
                switch (result->flag) {
                case ISP_UNKNOWN:
                case ISP_MISSED:

Reply via email to