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>
This commit is contained in:
Alexandre Julliard 2008-01-08 14:49:09 +01:00 committed by Junio C Hamano
parent 58152a02d9
commit ef40b3efe0

View File

@ -538,10 +538,10 @@ and returns the process output as a string."
('ignored (propertize "Ignored " 'face 'git-ignored-face)) ('ignored (propertize "Ignored " 'face 'git-ignored-face))
(t "? "))) (t "? ")))
(defun git-file-type-as-string (info) (defun git-file-type-as-string (old-perm new-perm)
"Return a string describing the file type of INFO." "Return a string describing the file type based on its permissions."
(let* ((old-type (lsh (or (git-fileinfo->old-perm info) 0) -9)) (let* ((old-type (lsh (or old-perm 0) -9))
(new-type (lsh (or (git-fileinfo->new-perm info) 0) -9)) (new-type (lsh (or new-perm 0) -9))
(str (case new-type (str (case new-type
(?\100 ;; file (?\100 ;; file
(case old-type (case old-type
@ -590,12 +590,14 @@ and returns the process output as a string."
(defun git-fileinfo-prettyprint (info) (defun git-fileinfo-prettyprint (info)
"Pretty-printer for the git-fileinfo structure." "Pretty-printer for the git-fileinfo structure."
(insert (concat " " (if (git-fileinfo->marked info) (propertize "*" 'face 'git-mark-face) " ") (let ((old-perm (git-fileinfo->old-perm info))
" " (git-status-code-as-string (git-fileinfo->state info)) (new-perm (git-fileinfo->new-perm info)))
" " (git-permissions-as-string (git-fileinfo->old-perm info) (git-fileinfo->new-perm info)) (insert (concat " " (if (git-fileinfo->marked info) (propertize "*" 'face 'git-mark-face) " ")
" " (git-escape-file-name (git-fileinfo->name info)) " " (git-status-code-as-string (git-fileinfo->state info))
(git-file-type-as-string info) " " (git-permissions-as-string old-perm new-perm)
(git-rename-as-string info)))) " " (git-escape-file-name (git-fileinfo->name info))
(git-file-type-as-string old-perm new-perm)
(git-rename-as-string info)))))
(defun git-insert-info-list (status infolist) (defun git-insert-info-list (status infolist)
"Insert a list of file infos in the status buffer, replacing existing ones if any." "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."
(let ((info (pop infolist)) (let ((info (pop infolist))
(node (ewoc-nth status 0))) (node (ewoc-nth status 0)))
(while info (while info
(setf (git-fileinfo->needs-refresh info) t)
(cond ((not node) (cond ((not node)
(setq node (ewoc-enter-last status info)) (setq node (ewoc-enter-last status info))
(setq info (pop infolist))) (setq info (pop infolist)))
@ -617,6 +618,7 @@ and returns the process output as a string."
(git-fileinfo->name info)) (git-fileinfo->name info))
;; preserve the marked flag ;; preserve the marked flag
(setf (git-fileinfo->marked info) (git-fileinfo->marked (ewoc-data node))) (setf (git-fileinfo->marked info) (git-fileinfo->marked (ewoc-data node)))
(setf (git-fileinfo->needs-refresh info) t)
(setf (ewoc-data node) info) (setf (ewoc-data node) info)
(setq info (pop infolist))) (setq info (pop infolist)))
(t (t