@matheusbsbs / matheus-bagliano / commits / ef40b3efe0
Fork 0

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>

Alexandre Julliard committed Jan 8, 2008 at 14:49 UTC ef40b3efe0764f7b56c2745601690e9cc12428d8
1 file changed +13 -11
contrib/emacs/git.el
+13 -11
@@ -538,10 +538,10 @@ and returns the process output as a string."
538 ('ignored (propertize "Ignored " 'face 'git-ignored-face))
539 (t "? ")))
540
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))
545 (str (case new-type
546 (?\100 ;; file
547 (case old-type
@@ -590,12 +590,14 @@ and returns the process output as a string."
590
591 (defun git-fileinfo-prettyprint (info)
592 "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)))))
601
602 (defun git-insert-info-list (status infolist)
603 "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."
608 (let ((info (pop infolist))
609 (node (ewoc-nth status 0)))
610 (while info
609 - (setf (git-fileinfo->needs-refresh info) t)
611 (cond ((not node)
612 (setq node (ewoc-enter-last status info))
613 (setq info (pop infolist)))
@@ -617,6 +618,7 @@ and returns the process output as a string."
618 (git-fileinfo->name info))
619 ;; preserve the marked flag
620 (setf (git-fileinfo->marked info) (git-fileinfo->marked (ewoc-data node)))
621 + (setf (git-fileinfo->needs-refresh info) t)
622 (setf (ewoc-data node) info)
623 (setq info (pop infolist)))
624 (t