changeset 68495:1239e70c4e3c

* image-mode.el (image-toggle-display): Use file name if possible, instead of unnecessarily allocating a (possibly huge) lisp string.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 30 Jan 2006 20:44:44 +0000
parents 345dfaf46113
children ffc5a0380db7
files lisp/ChangeLog lisp/image-mode.el
diffstat 2 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Jan 30 19:58:41 2006 +0000
+++ b/lisp/ChangeLog	Mon Jan 30 20:44:44 2006 +0000
@@ -1,3 +1,8 @@
+2006-01-30  Chong Yidong  <cyd@stupidchicken.com>
+
+	* image-mode.el (image-toggle-display): Use file name if possible,
+	instead of unnecessarily allocating a (possibly huge) lisp string.
+
 2006-01-30  John Paul Wallington  <jpw@pobox.com>
 
 	* subr.el (toplevel): Define `cl-assertion-failed' condition here
--- a/lisp/image-mode.el	Mon Jan 30 19:58:41 2006 +0000
+++ b/lisp/image-mode.el	Mon Jan 30 20:44:44 2006 +0000
@@ -137,11 +137,14 @@
 	    (message "Repeat this command to go back to displaying the image")))
     ;; Turn the image data into a real image, but only if the whole file
     ;; was inserted
-    (let* ((data
-	    (string-make-unibyte
-	     (buffer-substring-no-properties (point-min) (point-max))))
-	   (image
-	    (create-image data nil t))
+    (let* ((image
+	    (if (and (buffer-file-name)
+		     (not (buffer-modified-p)))
+		(create-image (buffer-file-name))
+	      (create-image
+	       (string-make-unibyte
+		(buffer-substring-no-properties (point-min) (point-max)))
+	       nil t)))
 	   (props
 	    `(display ,image
 		      intangible ,image