summaryrefslogtreecommitdiff
path: root/lisp/image-dired.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-10-22 01:04:36 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2017-10-22 01:07:32 -0700
commit3aee7be62eaf8caef6f2fab31bee79674b3abbb7 (patch)
tree29226a5776f2ded9966138b98b5cef15b50ce463 /lisp/image-dired.el
parent2bfa42855bf0278497f2e4540eac2086dab254c3 (diff)
downloademacs-3aee7be62eaf8caef6f2fab31bee79674b3abbb7.tar.gz
Avoid unnecessary rounding errors in timestamps
Avoid the rounding errors of float-time when it’s easy. E.g., replace (< (float-time a) (float-time b)) with (time-less-p a b). * lisp/desktop.el (desktop-save): * lisp/ecomplete.el (ecomplete-add-item): * lisp/epg.el (epg-wait-for-completion): * lisp/files.el (dir-locals-find-file, dir-locals-read-from-dir): * lisp/image-dired.el (image-dired-get-thumbnail-image) (image-dired-create-thumb-1): * lisp/info.el (info-insert-file-contents): * lisp/ls-lisp.el (ls-lisp-format-time): * lisp/net/ange-ftp.el (ange-ftp-file-newer-than-file-p) (ange-ftp-verify-visited-file-modtime): * lisp/net/rcirc.el (rcirc-ctcp-sender-PING): * lisp/textmodes/remember.el (remember-store-in-mailbox): * lisp/url/url-cookie.el (url-cookie-expired-p): Bypass float-time to avoid rounding errors. * lisp/files.el (dir-locals-find-file):
Diffstat (limited to 'lisp/image-dired.el')
-rw-r--r--lisp/image-dired.el15
1 files changed, 7 insertions, 8 deletions
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 30ecc2befc7..175d9df5e8c 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -582,10 +582,11 @@ Create the thumbnails directory if it does not exist."
"Return the image descriptor for a thumbnail of image file FILE."
(unless (string-match (image-file-name-regexp) file)
(error "%s is not a valid image file" file))
- (let ((thumb-file (image-dired-thumb-name file)))
- (unless (and (file-exists-p thumb-file)
- (<= (float-time (nth 5 (file-attributes file)))
- (float-time (nth 5 (file-attributes thumb-file)))))
+ (let* ((thumb-file (image-dired-thumb-name file))
+ (thumb-attr (file-attributes thumb-file)))
+ (when (or (not thumb-attr)
+ (time-less-p (nth 5 thumb-attr)
+ (nth 5 (file-attributes file))))
(image-dired-create-thumb file thumb-file))
(create-image thumb-file)
;; (list 'image :type 'jpeg
@@ -748,10 +749,8 @@ Increase at own risk.")
'image-dired-cmd-create-thumbnail-program)
(let* ((width (int-to-string (image-dired-thumb-size 'width)))
(height (int-to-string (image-dired-thumb-size 'height)))
- (modif-time
- (format "%.0f"
- (ffloor (float-time
- (nth 5 (file-attributes original-file))))))
+ (modif-time (format-time-string
+ "%s" (nth 5 (file-attributes original-file))))
(thumbnail-nq8-file (replace-regexp-in-string ".png\\'" "-nq8.png"
thumbnail-file))
(spec