summaryrefslogtreecommitdiff
path: root/lisp/pdf-cache.el
diff options
context:
space:
mode:
authorNathaniel Nicandro <nathanielnicandro@gmail.com>2018-12-25 04:05:24 -0600
committerNathaniel Nicandro <nathanielnicandro@gmail.com>2019-01-08 22:35:20 -0600
commit44a7db696e6bab66d122578dbeac1897d7d264f2 (patch)
tree3b9a7baaeb955985835d185ca5a8344fa9c63d4d /lisp/pdf-cache.el
parenta4cd69ea1d50b8e74ea515eec95948ad87c6c732 (diff)
Handle edge case when getting image data from the head of the cache
Diffstat (limited to 'lisp/pdf-cache.el')
-rw-r--r--lisp/pdf-cache.el19
1 files changed, 7 insertions, 12 deletions
diff --git a/lisp/pdf-cache.el b/lisp/pdf-cache.el
index 49b86d7..ea4182f 100644
--- a/lisp/pdf-cache.el
+++ b/lisp/pdf-cache.el
@@ -207,21 +207,16 @@ width MAX-WIDTH and `eql' hash value.
Remember that image was recently used.
Returns nil, if no matching image was found."
- (let ((cache (cons nil pdf-cache--image-cache))
+ (let ((cache pdf-cache--image-cache)
image)
- ;; Find it in the cache and remove it. We need to find the
- ;; element in front of it.
- (while (and (cdr cache)
+ ;; Find it in the cache.
+ (while (and (setq image (pop cache))
(not (pdf-cache--image-match
- (car (cdr cache))
- page min-width max-width hash)))
- (setq cache (cdr cache)))
- (setq image (cadr cache))
- (when (car cache)
- (setcdr cache (cddr cache)))
- ;; Now push it at the front.
+ image page min-width max-width hash))))
+ ;; Remove it and push it to the front.
(when image
- (push image pdf-cache--image-cache)
+ (setq pdf-cache--image-cache
+ (cons image (delq image pdf-cache--image-cache)))
(pdf-cache--image/data image))))
(defun pdf-cache-put-image (page width data &optional hash)