From 2bd53dc0718af4f3184d213f096bde5bbcc46a90 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Mon, 30 Jan 2006 20:44:44 +0000 Subject: * image-mode.el (image-toggle-display): Use file name if possible, instead of unnecessarily allocating a (possibly huge) lisp string. --- lisp/image-mode.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lisp/image-mode.el') diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 67d1bcee995..3c0544edf89 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -137,11 +137,14 @@ and showing the image as an image." (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 -- cgit v1.2.3