Subject: bug#27622: closed (Re: bug#27622: Trying to improve the speed of linum-mode)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 09 Jul 2017 18:28:03 +0000

Your bug report

#27622: Trying to improve the speed of linum-mode

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
27622: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27622
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#27622: Trying to improve the speed of linum-mode
From: Eli Zaretskii <[email-masked]>
To: Fis Trivial <[email-masked]>
Cc: [email-masked]
Date: Sun, 09 Jul 2017 21:27:25 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Fis Trivial <[email-masked]>
> CC: "[email-masked]" <[email-masked]>
> Date: Sun, 9 Jul 2017 18:06:18 +0000
> 
> It's great. Now the Emacs works perfectly. Thanks for your work.

Thanks, closing.

Subject: Trying to improve the speed of linum-mode
From: Fis Trivial <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Sat, 8 Jul 2017 09:25:38 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

For some reasons, the linum-mode needs to go over the whole buffer in
order to update the line numbers. It's ok when viewing a small buffer,
but when comes to something large it will slow the emacs down like I
was viewing a ppt(try kernel patch). I don't really understand the
code, but I changed it a little bit and it works fine so far. Here is
the patch, linum-o.el is the original code:

--- linum-o.el	2017-06-06 09:04:32.012568000 +0800
+++ linum.el	2017-07-
08 16:45:45.710518928 +0800
@@ -174,7 +174,7 @@
         (fmt (cond
((stringp linum-format) linum-format)
                    ((eq linum-
format 'dynamic)
                     (let ((w (length (number-to-string

-                                      (count-lines (point-min) (point-
max))))))
+                                      (count-lines (window-
start win) (window-end win t))))))
                       (concat "%"
(number-to-string w) "d")))))
         (width 0))
     (run-hooks 'linum-
before-numbering-hook)

The minor change replaced (point-min/max) to (window-start/end) which
saves a lots of iterations and did improve the speed at start-up. but
if I move the cursor to the end of the buffer, it slows down again and
I don't know why it's happening.
So, I got wonder is there any particular reason to use (point-min)
instead of (window-start)? And what's the cause of slowing down when I
move the cursor to the end of buffer?