emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/relint 4fcc322 16/21: Delay call to file-relative-name


From: Mattias Engdegård
Subject: [elpa] externals/relint 4fcc322 16/21: Delay call to file-relative-name until needed
Date: Sun, 3 May 2020 11:13:38 -0400 (EDT)

branch: externals/relint
commit 4fcc3220975815471242dff222d9316d58920c53
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Delay call to file-relative-name until needed
    
    ENCODE_FILE and DECODE_FILE, present in many file and filename
    manipulation primitives, are quite expensive and allocate a lot, even
    when names are pure ASCII.
    
    We don't actually need to call file-relative-name until there is a
    diagnostic emitted for that file, so evaluate it lazily.
    
    This should really be fixed in Emacs, but meanwhile this mitigation
    doesn't hurt.
---
 relint.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/relint.el b/relint.el
index 1adcaee..e2eefcf 100644
--- a/relint.el
+++ b/relint.el
@@ -91,6 +91,7 @@
 (require 'xr)
 (require 'compile)
 (require 'cl-lib)
+(require 'thunk)
 
 (defvar relint--error-buffer)
 (defvar relint--quiet)
@@ -263,7 +264,8 @@ or nil if no position could be determined."
          (error-pos (and str-idx (relint--string-pos expr-pos str-idx))))
     (if (relint--suppression expr-pos message)
         (setq relint--suppression-count (1+ relint--suppression-count))
-      (funcall relint--report-function file expr-pos error-pos message
+      (funcall relint--report-function
+               (thunk-force file) expr-pos error-pos message
                str str-idx severity)))
   (setq relint--error-count (1+ relint--error-count)))
 
@@ -2191,8 +2193,11 @@ Return a list of (FORM . STARTING-POSITION)."
   (with-temp-buffer
     (emacs-lisp-mode)
     (insert-file-contents file)
-    (relint--scan-current-buffer (file-relative-name file base-dir))))
-        
+    ;; Call file-relative-name lazily -- it is surprisingly expensive
+    ;; on macOS, and the result only used for diagnostics output.
+    (relint--scan-current-buffer
+     (thunk-delay (file-relative-name file base-dir)))))
+
 (defvar relint-last-target nil
   "The last file, directory or buffer on which relint was run.")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]