git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Julliard <julliard@winehq.org>
To: git@vger.kernel.org
Subject: [PATCH 3/3] git.el: Make status refresh faster.
Date: Tue, 08 Jan 2008 14:49:09 +0100	[thread overview]
Message-ID: <87r6gsig16.fsf@wine.dyndns.org> (raw)

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>
---
 contrib/emacs/git.el |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 825b1e9..8f39ebe 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -538,10 +538,10 @@ and returns the process output as a string."
     ('ignored  (propertize "Ignored " 'face 'git-ignored-face))
     (t "?       ")))
 
-(defun git-file-type-as-string (info)
-  "Return a string describing the file type of INFO."
-  (let* ((old-type (lsh (or (git-fileinfo->old-perm info) 0) -9))
-	 (new-type (lsh (or (git-fileinfo->new-perm info) 0) -9))
+(defun git-file-type-as-string (old-perm new-perm)
+  "Return a string describing the file type based on its permissions."
+  (let* ((old-type (lsh (or old-perm 0) -9))
+         (new-type (lsh (or new-perm 0) -9))
 	 (str (case new-type
 		(?\100  ;; file
 		 (case old-type
@@ -590,12 +590,14 @@ and returns the process output as a string."
 
 (defun git-fileinfo-prettyprint (info)
   "Pretty-printer for the git-fileinfo structure."
-  (insert (concat "   " (if (git-fileinfo->marked info) (propertize "*" 'face 'git-mark-face) " ")
-                  " " (git-status-code-as-string (git-fileinfo->state info))
-                  " " (git-permissions-as-string (git-fileinfo->old-perm info) (git-fileinfo->new-perm info))
-                  "  " (git-escape-file-name (git-fileinfo->name info))
-		  (git-file-type-as-string info)
-                  (git-rename-as-string info))))
+  (let ((old-perm (git-fileinfo->old-perm info))
+        (new-perm (git-fileinfo->new-perm info)))
+    (insert (concat "   " (if (git-fileinfo->marked info) (propertize "*" 'face 'git-mark-face) " ")
+                    " " (git-status-code-as-string (git-fileinfo->state info))
+                    " " (git-permissions-as-string old-perm new-perm)
+                    "  " (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)
   "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))
         (node (ewoc-nth status 0)))
     (while info
-      (setf (git-fileinfo->needs-refresh info) t)
       (cond ((not node)
              (setq node (ewoc-enter-last status info))
              (setq info (pop infolist)))
@@ -617,6 +618,7 @@ and returns the process output as a string."
                            (git-fileinfo->name info))
               ;; preserve the marked flag
               (setf (git-fileinfo->marked info) (git-fileinfo->marked (ewoc-data node)))
+              (setf (git-fileinfo->needs-refresh info) t)
               (setf (ewoc-data node) info)
               (setq info (pop infolist)))
             (t
-- 
1.5.4.rc2.71.ge10a9

-- 
Alexandre Julliard
julliard@winehq.org

                 reply	other threads:[~2008-01-08 13:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r6gsig16.fsf@wine.dyndns.org \
    --to=julliard@winehq.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).