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

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

[elpa] externals/ggtags c536ec5 5/9: Cache number of lines from previous


From: Stefan Monnier
Subject: [elpa] externals/ggtags c536ec5 5/9: Cache number of lines from previous output in `ggtags-global-output`
Date: Fri, 26 Mar 2021 22:46:20 -0400 (EDT)

branch: externals/ggtags
commit c536ec559dbfcd57644c98494a837f260ef3dfbe
Author: Nathaniel Nicandro <nathanielnicandro@gmail.com>
Commit: Leo Liu <sdl.web@gmail.com>

    Cache number of lines from previous output in `ggtags-global-output`
    
    `line-number-at-pos` grows linearly with the number of lines in a buffer so
    cache the computation of the number of lines and only call 
`line-number-at-pos`
    when the buffer is narrowed to new output produced by Global that has not 
been
    processed yet.
---
 ggtags.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ggtags.el b/ggtags.el
index 94dc62c..834123f 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -1994,6 +1994,10 @@ If SYNC is non-nil, synchronously run CMDS and call 
CALLBACK."
                         (with-current-buffer (process-buffer proc)
                           (goto-char (process-mark proc))
                           (insert string)
+                          (save-restriction
+                            (narrow-to-region (process-mark proc) (point))
+                            (cl-incf (process-get proc :nlines)
+                                     (line-number-at-pos (1- (point)))))
                           (set-marker (process-mark proc) (point))
                           (when (and (> (line-number-at-pos (point-max)) 
cutoff)
                                      (process-live-p proc))
@@ -2009,6 +2013,7 @@ If SYNC is non-nil, synchronously run CMDS and call 
CALLBACK."
     (and cutoff (set-process-filter proc filter))
     (set-process-sentinel proc sentinel)
     (process-put proc :callback-done nil)
+    (process-put proc :nlines 0)
     (if sync (while (not (process-get proc :callback-done))
                (accept-process-output proc 1))
       proc)))



reply via email to

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