[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/spell-fu bd76cb262e 15/86: Avoid 2x loops over the pending
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/spell-fu bd76cb262e 15/86: Avoid 2x loops over the pending screen overlays |
Date: |
Thu, 7 Jul 2022 12:03:39 -0400 (EDT) |
branch: elpa/spell-fu
commit bd76cb262e6250869e985fee5437e5e6ad5550e2
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Avoid 2x loops over the pending screen overlays
---
spell-fu.el | 71 ++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 37 insertions(+), 34 deletions(-)
diff --git a/spell-fu.el b/spell-fu.el
index 1f0e5edebc..daaa897494 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -496,43 +496,46 @@ range POINT-START to POINT-END. Otherwise remove all
overlays."
( ;; Don't show the cursor motion from spell checking.
(visible-start (window-start))
(visible-end (window-end))
-
- (overlays-in-view
- (seq-filter
- (lambda (item-ov) (eq (overlay-get item-ov 'spell-fu-pending) t))
- (overlays-in visible-start visible-end))))
+ (overlays-in-view (overlays-in visible-start visible-end)))
(while overlays-in-view
- (let*
- ( ;; Window clamped range.
- (item-ov (pop overlays-in-view))
- (point-start (max visible-start (overlay-start item-ov)))
- (point-end (min visible-end (overlay-end item-ov))))
-
- ;; Expand so we don't spell check half a word.
- (spell-fu--expand-range-to-line-boundaries point-start point-end)
-
+ (let ((item-ov (pop overlays-in-view)))
(when
- (condition-case err
- ;; Needed so the idle timer won't quit mid-spelling.
- (let ((inhibit-quit nil))
- (funcall spell-fu-check-range point-start point-end)
- t)
- (error
- (progn
- ;; Keep since this should be very rare.
- (message "Early exit 'spell-fu-mode': %s"
(error-message-string err))
- ;; Break out of the loop.
- (setq overlays-in-view nil)
- nil)))
-
- ;; Don't delete the overlay since it may extend outside the window
bounds,
- ;; always delete the range instead.
- (spell-fu--idle-remove-overlays point-start point-end)
-
- ;; Ensure the next overlay hasn't been removed.
- (while (and overlays-in-view (null (overlay-buffer (car
overlays-in-view))))
- (pop overlays-in-view))))))))
+ (and
+ (overlay-get item-ov 'spell-fu-pending)
+ ;; It's possible these become invalid while looping over items.
+ (overlay-buffer item-ov))
+
+ (let
+ ( ;; Window clamped range.
+ (point-start (max visible-start (overlay-start item-ov)))
+ (point-end (min visible-end (overlay-end item-ov))))
+
+ ;; Expand so we don't spell check half a word.
+ (spell-fu--expand-range-to-line-boundaries point-start point-end)
+
+ (when
+ (condition-case err
+ ;; Needed so the idle timer won't quit mid-spelling.
+ (let ((inhibit-quit nil))
+ (funcall spell-fu-check-range point-start point-end)
+ t)
+ (error
+ (progn
+ ;; Keep since this should be very rare.
+ (message "Early exit 'spell-fu-mode': %s"
(error-message-string err))
+ ;; Break out of the loop.
+ (setq overlays-in-view nil)
+ nil)))
+
+ ;; Don't delete the overlay since it may extend outside the
window bounds,
+ ;; always delete the range instead.
+ ;;
+ ;; While we could remove everything in the window range,
+ ;; avoid this because it's possible `spell-fu-check-range' is
interrupted.
+ ;; Allowing interrupting is important, so users may set this
to a slower function
+ ;; which doesn't lock up Emacs as this is run from an idle
timer.
+ (spell-fu--idle-remove-overlays point-start point-end)))))))))
(defun spell-fu--idle-font-lock-region-pending (point-start point-end)
"Track the range to spell check, adding POINT-START & POINT-END to the
queue."
- [nongnu] elpa/spell-fu 3a19836c69 78/86: Cleanup: use brief SPDX license, (continued)
- [nongnu] elpa/spell-fu 3a19836c69 78/86: Cleanup: use brief SPDX license, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1698c51740 79/86: Store a list of hashes instead of symbol lookups for each word, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 47d92c1989 84/86: Fix wrong function name for multiple languages example, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 2590ee3002 80/86: Cleanup: remove cl-remove-if-not, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1299bfca2e 85/86: Merge pull request 'Fix wrong function name for multiple languages example' (#27) from kepi/emacs-spell-fu:master into master, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 907271a557 03/86: Cleanup: unnecessary 'let' nesting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 3898e6f591 04/86: Cleanup: remove use of exception handling, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu ae4504f14d 07/86: Fix using hard coded en_US dictionary, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu f2b7d58e87 08/86: Cleanup: correct comment, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1e6928f77d 05/86: Cleanup: add message for generating cache, some comments, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu bd76cb262e 15/86: Avoid 2x loops over the pending screen overlays,
ELPA Syncer <=
- [nongnu] elpa/spell-fu 4f9732492c 01/86: Initial code., ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 6a7440044e 19/86: Cleanup: rename variables to make the assignment explicit, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 5915e0ae2a 24/86: Cleanup: use safer sharp-quoted function names, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 3f4fc34204 32/86: Add 'spell-fu-buffer' utility, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu ddad489f2c 43/86: Adds affix dict support via aspell expand cmd, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu ce64f4bc4d 51/86: Cleanup: remove arguments that are always fixed, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1b765f8029 58/86: Cleanup: replace setq with let binding, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1159eeec13 63/86: Fix including trailing single-quote in the word, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 32fcbd9e8e 68/86: Initial changes for multiple dictionaries, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1f3e5b8f05 72/86: readme: Fix typos, ELPA Syncer, 2022/07/07