Subject: bug#32225: closed (Re: bug#32225: 27.0.50; [PATCH] avoid calling vc backend if vc-display-status is nil)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 11 Aug 2018 10:07:02 +0000

Your bug report

#32225: 27.0.50; [PATCH] avoid calling vc backend if vc-display-status is nil

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
32225: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=32225
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#32225: 27.0.50; [PATCH] avoid calling vc backend if vc-display-status is nil
From: Eli Zaretskii <[email-masked]>
To: Andy Moreton <[email-masked]>
Cc: [email-masked]
Date: Sat, 11 Aug 2018 13:05:58 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Andy Moreton <[email-masked]>
> Date: Fri, 20 Jul 2018 17:45:09 +0100
> 
> If the user sets `vc-display-status' to nil then the VC backend is still
> called to get a revision number, even though it will not be displayed.
> 
> The following patch avoids this unneeded work.

Thanks, pushed to the master branch.

Subject: 27.0.50; [PATCH] avoid calling vc backend if vc-display-status is nil
From: Andy Moreton <[email-masked]>
To: [email-masked]
Date: Fri, 20 Jul 2018 17:45:09 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

If the user sets `vc-display-status' to nil then the VC backend is still
called to get a revision number, even though it will not be displayed.

The following patch avoids this unneeded work.

Do not call VC backend to update mode line if vc-display-status is nil

2018-07-20  Andy Moreton  <[email-masked]>

	* lisp/vc/vc-hooks.el (vc-mode-line): Avoid calling VC backend if
	vc-display-status is nil.

diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 55c0132bf2..f1b622b54a 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -692,24 +692,26 @@ vc-mode-line
  If BACKEND is passed use it as the VC backend when computing the result."
    (interactive (list buffer-file-name))
    (setq backend (or backend (vc-backend file)))
-  (if (not backend)
-      (setq vc-mode nil)
+  (cond
+   ((not backend)
+    (setq vc-mode nil))
+   ((null vc-display-status)
+    (setq vc-mode (concat " " (symbol-name backend))))
+   (t
      (let* ((ml-string (vc-call-backend backend 'mode-line-string file))
  	   (ml-echo (get-text-property 0 'help-echo ml-string)))
        (setq vc-mode
  	    (concat
  	     " "
-	     (if (null vc-display-status)
-		 (symbol-name backend)
-	       (propertize
-		ml-string
-		'mouse-face 'mode-line-highlight
-		'help-echo
-		(concat (or ml-echo
-			    (format "File under the %s version control system"
-				    backend))
-			"\nmouse-1: Version Control menu")
-		'local-map vc-mode-line-map)))))
+	     (propertize
+	      ml-string
+	      'mouse-face 'mode-line-highlight
+	      'help-echo
+	      (concat (or ml-echo
+			  (format "File under the %s version control system"
+				  backend))
+		      "\nmouse-1: Version Control menu")
+	      'local-map vc-mode-line-map))))
      ;; If the user is root, and the file is not owner-writable,
      ;; then pretend that we can't write it
      ;; even though we can (because root can write anything).
@@ -718,7 +720,7 @@ vc-mode-line
  	 (not buffer-read-only)
  	 (zerop (user-real-uid))
  	 (zerop (logand (file-modes buffer-file-name) 128))
-	 (setq buffer-read-only t)))
+	 (setq buffer-read-only t))))
    (force-mode-line-update)
    backend)

In GNU Emacs 27.0.50 (build 21, x86_64-w64-mingw32)
  of 2018-07-20 built on AJM-DESKTOP2
Repository revision: 249606fb539bd1a7dc95129277c1684826fc068f
Windowing system distributor 'Microsoft Corp.', version 10.0.16299
Recent messages:
Finding changes in c:/emacs/git/emacs/master/lisp/vc/vc-hooks.el...
Running in foreground: git --no-pager diff-index --exit-code -p HEAD  -- 
vc-hooks.el
Done (status=1): git --no-pager diff-index --exit-code -p HEAD  -- vc-hooks.el
Finding changes in c:/emacs/git/emacs/master/lisp/vc/vc-hooks.el...done
Mark activated
Mark set
Saved text from "diff --git a/lisp/vc/vc-hooks.el b/lisp/"
Mark set
Saving file c:/home/ajm/sandbox/emacs/vc-mode-line.patch...
Wrote c:/home/ajm/sandbox/emacs/vc-mode-line.patch

Configured using:
  'configure --prefix=/c/emacs/emacs-master --without-dbus --with-gif
  --with-gnutls --without-imagemagick --with-jpeg --with-json
  --with-lcms2 --with-modules --with-png --without-pop --with-rsvg
  --with-tiff --with-xml2 --with-xpm --enable-checking 'CFLAGS= -Og -g3
  -gdwarf-4 -fdiagnostics-color=never'
  PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS MODULES THREADS JSON LCMS2

Important settings:
   value of $LANG: ENG
   locale-coding-system: cp1252

Major mode: Diff

Minor modes in effect:
   whitespace-mode: t
   bug-reference-prog-mode: t
   shell-dirtrack-mode: t
   which-function-mode: t
   fci-mode: t
   desktop-save-mode: t
   show-paren-mode: t
   auto-image-file-mode: t
   minibuffer-electric-default-mode: t
   override-global-mode: t
   tooltip-mode: t
   global-eldoc-mode: t
   mouse-wheel-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-compression-mode: t
   column-number-mode: t
   line-number-mode: t
   transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow emacsbug sendmail whitespace vc-dir ewoc vc-filewise log-view
pcvs-util vc-annotate vc arc-mode archive-mode vc-git eieio-opt speedbar
sb-image ezimage dframe cl-print cc-langs help-fns radix-tree sh-script
smie executable find-dired grep url-http url-gw url-auth url-queue
url-cache url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf shr text-property-search svg xml dom thingatpt qp
flow-fill mm-archive browse-url misearch multi-isearch add-log sort
mail-extr gnus-async gnus-bcklg gnus-ml gnus-topic nndraft nnmh
network-stream nnml nnnil gnus-cite gnus-agent gnus-srvr gnus-score
score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime
smime dig mailcap nntp gnus-cache ibuf-ext ibuf-macs ibuffer
ibuffer-loaddefs time face-remap dired-aux url-util elec-pair org-rmail
org-mhe org-irc org-info org-gnus nnir gnus-sum gnus-group gnus-undo
gnus-start gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo
gnus-spec gnus-int gnus-range message rfc822 mml mml-sec epa mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
gnus-win gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045
ietf-drums mail-utils mm-util mail-prsvr org-docview doc-view jka-compr
image-mode org-bibtex bibtex org-bbdb org-w3m org-element avl-tree
generator org org-macro org-footnote org-pcomplete org-list org-faces
org-entities noutline outline org-version ob-plantuml ob-dot ob-ditaa
ob-shell ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob ob-table
ob-keys ob-exp ob-comint ob-core ob-eval org-compat org-macs
org-loaddefs find-func cal-menu calendar cal-loaddefs dired
dired-loaddefs macrostep-c cmacexp macrostep pp cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
vc-dispatcher vc-hg bug-reference xcscope diff-mode python tramp-sh
tramp trampver tramp-compat tramp-loaddefs ucs-normalize parse-time
format-spec cap-words superword subword etags xref project compile
htmlize cl info-look man shell pcomplete which-func imenu
fill-column-indicator rx edmacro kmacro desktop frameset cygwin-mount
ange-ftp comint ansi-color ring hl-line paren image-file minibuf-eldef
cus-edit cus-start cus-load wid-edit warnings delight advice use-package
use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key easy-mmode use-package-core nsm rmc gnutls
puny time-date mule-util info finder-inf package let-alist derived pcase
cl-extra help-mode easymenu url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars
seq byte-opt gv bytecomp byte-compile cconv epg epg-config subr-x
cl-loaddefs cl-lib tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win
w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads w32notify w32 lcms2 multi-tty make-network-process
emacs)

Memory information:
((conses 16 1030451 701809)
  (symbols 56 51267 49)
  (miscs 48 8386 7418)
  (strings 32 133014 56086)
  (string-bytes 1 4364350)
  (vectors 16 80615)
  (vector-slots 8 2109657 426454)
  (floats 8 406 1933)
  (intervals 56 77681 13720)
  (buffers 992 105))