emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil-goggles d3222f8b07 219/225: speedup: count-lines inst


From: ELPA Syncer
Subject: [nongnu] elpa/evil-goggles d3222f8b07 219/225: speedup: count-lines instead of substracting line-number-at-pos's
Date: Wed, 12 Jan 2022 08:59:10 -0500 (EST)

branch: elpa/evil-goggles
commit d3222f8b075438ea111a3a002ca4a625e66fe203
Author: Kevin Brubeck Unhammer <unhammer@fsfe.org>
Commit: Kevin Brubeck Unhammer <unhammer@fsfe.org>

    speedup: count-lines instead of substracting line-number-at-pos's
    
    Before this change, doing a simple `x` on line 144213 of a big file
    would make line-number-at-pos count lines from point-min, taking
    several seconds on my machine. Since we're looking for both beg and
    end (which happen to be one character apart), this counts all 144213
    lines twice. The count-lines function instead narrows the buffer
    first, eradicating the slowdown.
    
    (See
    
https://bitbucket.org/lyro/evil/pull-requests/32/count-lines-much-faster-than-subtracting/diff
    which regards a similar change to evil.)
---
 evil-goggles.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/evil-goggles.el b/evil-goggles.el
index 1690a0237f..fe25914c3d 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -136,7 +136,7 @@ background of 'evil-goggles-default-face, then 'region."
        (numberp end)
        ;; don't show overlay if the region is a single char on a single line
        (not (and (<= (- end beg) 1)
-                 (= (line-number-at-pos beg) (line-number-at-pos end))))
+                 (<= (count-lines beg end) 1)))
        (<= (point-min) beg end)
        (>= (point-max) end beg)
        (not (evil-visual-state-p))
@@ -415,7 +415,7 @@ BEG and END are the argumenets to the original functions."
   (when (and (called-interactively-p 'interactive)
              (evil-goggles--show-p beg end)
              ;; don't show goggles for single lines ("J"/"gJ" without count)
-             (< 1 (- (line-number-at-pos end) (line-number-at-pos beg))))
+             (< 1 (count-lines beg end)))
     (evil-goggles--show-blocking-hint beg end)))
 
 ;;; fill



reply via email to

[Prev in Thread] Current Thread [Next in Thread]