Skip to content

Commit ef40b3e

Browse files
julliardgitster
authored andcommitted
git.el: Make status refresh faster.
Don't set the needs-refresh flag when inserting a new file info, since ewoc refreshes it upon insert already; this makes a full refresh twice as fast. Also make git-fileinfo-prettyprint a little faster by not retrieving permission values twice. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 58152a0 commit ef40b3e

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

contrib/emacs/git.el

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,10 @@ and returns the process output as a string."
538538
('ignored (propertize "Ignored " 'face 'git-ignored-face))
539539
(t "? ")))
540540

541-
(defun git-file-type-as-string (info)
542-
"Return a string describing the file type of INFO."
543-
(let* ((old-type (lsh (or (git-fileinfo->old-perm info) 0) -9))
544-
(new-type (lsh (or (git-fileinfo->new-perm info) 0) -9))
541+
(defun git-file-type-as-string (old-perm new-perm)
542+
"Return a string describing the file type based on its permissions."
543+
(let* ((old-type (lsh (or old-perm 0) -9))
544+
(new-type (lsh (or new-perm 0) -9))
545545
(str (case new-type
546546
(?\100 ;; file
547547
(case old-type
@@ -590,12 +590,14 @@ and returns the process output as a string."
590590

591591
(defun git-fileinfo-prettyprint (info)
592592
"Pretty-printer for the git-fileinfo structure."
593-
(insert (concat " " (if (git-fileinfo->marked info) (propertize "*" 'face 'git-mark-face) " ")
594-
" " (git-status-code-as-string (git-fileinfo->state info))
595-
" " (git-permissions-as-string (git-fileinfo->old-perm info) (git-fileinfo->new-perm info))
596-
" " (git-escape-file-name (git-fileinfo->name info))
597-
(git-file-type-as-string info)
598-
(git-rename-as-string info))))
593+
(let ((old-perm (git-fileinfo->old-perm info))
594+
(new-perm (git-fileinfo->new-perm info)))
595+
(insert (concat " " (if (git-fileinfo->marked info) (propertize "*" 'face 'git-mark-face) " ")
596+
" " (git-status-code-as-string (git-fileinfo->state info))
597+
" " (git-permissions-as-string old-perm new-perm)
598+
" " (git-escape-file-name (git-fileinfo->name info))
599+
(git-file-type-as-string old-perm new-perm)
600+
(git-rename-as-string info)))))
599601

600602
(defun git-insert-info-list (status infolist)
601603
"Insert a list of file infos in the status buffer, replacing existing ones if any."
@@ -606,7 +608,6 @@ and returns the process output as a string."
606608
(let ((info (pop infolist))
607609
(node (ewoc-nth status 0)))
608610
(while info
609-
(setf (git-fileinfo->needs-refresh info) t)
610611
(cond ((not node)
611612
(setq node (ewoc-enter-last status info))
612613
(setq info (pop infolist)))
@@ -617,6 +618,7 @@ and returns the process output as a string."
617618
(git-fileinfo->name info))
618619
;; preserve the marked flag
619620
(setf (git-fileinfo->marked info) (git-fileinfo->marked (ewoc-data node)))
621+
(setf (git-fileinfo->needs-refresh info) t)
620622
(setf (ewoc-data node) info)
621623
(setq info (pop infolist)))
622624
(t

0 commit comments

Comments
 (0)