emacs-devel
[Top][All Lists]
Advanced

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

Re: Redisplay slower in Emacs 28 than Emacs 27


From: Lars Ingebrigtsen
Subject: Re: Redisplay slower in Emacs 28 than Emacs 27
Date: Tue, 08 Dec 2020 00:44:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Gregory Heytings <ghe@sdf.org> writes:

>>
>> Hm.  Does adding a (require 'image) help?  Like this:
>>
>
> No it doesn't :-(

No, that one wasn't any good -- I didn't understand why it failed for
you and not for me, but it's a bootstrap problem.

This one should work, I think.  (Use instead of the other patch, not in
addition to.)

diff --git a/lisp/image.el b/lisp/image.el
index 9ebb603086..ee961ce577 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -679,8 +679,10 @@ image-search-load-path
       (setq path (cdr path)))
     (if found filename)))
 
+(defvar find-image--cache (make-hash-table :test #'equal))
+
 ;;;###autoload
-(defun find-image (specs)
+(defun find-image (specs &optional cache)
   "Find an image, choosing one of a list of image specifications.
 
 SPECS is a list of image specifications.
@@ -698,23 +700,29 @@ find-image
 The image is looked for in `image-load-path'.
 
 Image files should not be larger than specified by `max-image-size'."
-  (let (image)
-    (while (and specs (null image))
-      (let* ((spec (car specs))
-            (type (plist-get spec :type))
-            (data (plist-get spec :data))
-            (file (plist-get spec :file))
-            found)
-       (when (image-type-available-p type)
-         (cond ((stringp file)
-                (if (setq found (image-search-load-path file))
-                    (setq image
-                          (cons 'image (plist-put (copy-sequence spec)
-                                                  :file found)))))
-               ((not (null data))
-                (setq image (cons 'image spec)))))
-       (setq specs (cdr specs))))
-    image))
+  (or (and cache
+           (gethash specs find-image--cache))
+      (let ((orig-specs specs)
+            image)
+        (message "find: %S" specs)
+        (while (and specs (null image))
+          (let* ((spec (car specs))
+                (type (plist-get spec :type))
+                (data (plist-get spec :data))
+                (file (plist-get spec :file))
+                found)
+           (when (image-type-available-p type)
+             (cond ((stringp file)
+                    (if (setq found (image-search-load-path file))
+                        (setq image
+                              (cons 'image (plist-put (copy-sequence spec)
+                                                      :file found)))))
+                   ((not (null data))
+                    (setq image (cons 'image spec)))))
+           (setq specs (cdr specs))))
+        (when cache
+          (setf (gethash orig-specs find-image--cache) image))
+        image)))
 
 
 ;;;###autoload


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

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