Subject: bug#14423: 24.3; Gnus gratuitously loads image libraries in w32 text-mode Emacs

From: Ted Zlatanov <[email-masked]>
Date: Wed, 05 Jun 2013 11:18:21 -0400

On Sun, 19 May 2013 22:46:44 +0300 Eli Zaretskii <[email-masked]> wrote: 

EZ> Many Gnus features use the function gnus-image-type-available-p, which
EZ> does this:

EZ>    (defun gnus-image-type-available-p (type)
EZ>      (and (fboundp 'image-type-available-p)
EZ> 	  (image-type-available-p type)
EZ> 	  (if (fboundp 'display-images-p)
EZ> 	      (display-images-p)
EZ> 	    t)))

EZ> Because this calls image-type-available-p before testing the display
EZ> for image support (by calling display-images-p), a text-mode session
EZ> on MS-Windows will load image libraries that cannot be possibly useful
EZ> in a non-GUI session.  (The MS-Windows build of Emacs loads image DLL
EZ> shared libraries on demand, and that happens inside the call to
EZ> image-type-available-p.)  This useless library load both slows down
EZ> loading certain Gnus packages, and unnecessarily bloats the memory
EZ> footprint of the Emacs process.

EZ> To avoid this adverse effect, gnus-image-type-available-p should test
EZ> the result of calling display-images-p _before_ it checks whether the
EZ> specific image type can be supported.

That seems like a very trivial fix.  Does the patch below do it?  Or
should I make this check the very first thing?

Thanks
Ted

diff --git a/lisp/gnus-ems.el b/lisp/gnus-ems.el
index 4d9b579..f9ef70f 100644
--- a/lisp/gnus-ems.el
+++ b/lisp/gnus-ems.el
@@ -165,10 +165,10 @@
 
 (defun gnus-image-type-available-p (type)
   (and (fboundp 'image-type-available-p)
-       (image-type-available-p type)
        (if (fboundp 'display-images-p)
           (display-images-p)
-        t)))
+        t)
+       (image-type-available-p type)))
 
 (defun gnus-create-image (file &optional type data-p &rest props)
   (let ((face (plist-get props :face)))