all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] 5x speedup of flyspell-buffer
@ 2023-04-12 13:50 Ilya Zakharevich
  2023-04-13  6:54 ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Ilya Zakharevich @ 2023-04-12 13:50 UTC (permalink / raw)
  To: emacs-devel

With the included patch, on my system flyspell-buffer speeds up 5
times.  For my typical file sizes, this is 20sec -> 4sec on a 600K
LaTeX file with 10,000 words detected by `aspell´ — which makes
using flyspell feasible.

  The version is not the most recent, but IIUC, flyspell did not change.

(The number 1.05 below is chosen to lower overhead of messages 50 times,
from 5x to 0.1x.  It is related to log(10000)/0.05 ∼ 10000/50.)

Enjoy,
Ilya

--- 28.0.91/lisp/textmodes/flyspell.el-orig	2022-01-22 12:43:04.000000000 -0800
+++ 28.0.91/lisp/textmodes/flyspell.el	2023-04-12 06:31:39.836769300 -0700
@@ -1437,7 +1437,9 @@ The buffer to mark them in is `flyspell-
                              (if ispell-many-otherchars-p
                                  "*" "?")))
          (buffer-scan-pos flyspell-large-region-beg)
-         case-fold-search)
+         case-fold-search
+         (countw 0)
+         (countw-rep 0))
     (with-current-buffer flyspell-external-ispell-buffer
       (goto-char (point-min))
       ;; Loop over incorrect words, in the order they were reported,
@@ -1450,10 +1452,13 @@ The buffer to mark them in is `flyspell-
 	  ;; identical words, and the loop below would search for that many.
 	  ;; That code seemed to be incorrect, and on principle, should
 	  ;; be unnecessary too. -- rms.
-	  (if flyspell-issue-message-flag
-	      (message "Spell Checking...%d%% [%s]"
-		       (floor (* 100.0 (point)) (point-max))
-		       word))
+	  (setq countw (1+ countw))
+	  (when (and flyspell-issue-message-flag
+		     (> countw (* 1.05 countw-rep)))
+	    (setq countw-rep countw)
+	    (message "Spell Checking...%d%% [%s]"
+		     (floor (* 100.0 (point)) (point-max))
+		     word))
 	  (with-current-buffer flyspell-large-region-buffer
 	    (goto-char buffer-scan-pos)
 	    (let ((keep t))



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-04-15  2:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-12 13:50 [PATCH] 5x speedup of flyspell-buffer Ilya Zakharevich
2023-04-13  6:54 ` Eli Zaretskii
2023-04-13 10:23   ` Ilya Zakharevich
2023-04-13 10:32     ` Eli Zaretskii
2023-04-13 20:29       ` Ilya Zakharevich
2023-04-14  5:47         ` Eli Zaretskii
2023-04-14  6:39           ` Dr. Arne Babenhauserheide
2023-04-14  6:54             ` Eli Zaretskii
2023-04-15  1:51     ` interacting during (sit-for 0). Was: " Ilya Zakharevich
2023-04-15  2:01       ` Ilya Zakharevich

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.