Prefer nil to (current-time) when either will do

* lisp/emacs-lisp/timer.el (timer-event-handler, run-at-time):
* lisp/gnus/gnus-score.el (gnus-score-date):
* lisp/gnus/gnus-search.el (gnus-search-query-parse-date)
(gnus-search-imap-handle-date):
* lisp/gnus/gnus-sum.el (gnus-user-date)
(gnus-summary-create-article):
* lisp/image-dired.el (image-dired-create-thumb-1):
* lisp/image/gravatar.el (gravatar-retrieve)
(gravatar--prune-cache):
* lisp/net/dbus.el (dbus-monitor-handler):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-set-file-times):
* lisp/net/tramp-sh.el (tramp-sh-handle-set-file-times):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-set-file-times):
* test/lisp/autorevert-tests.el (auto-revert--wait-for-revert)
(auto-revert-tests--write-file, auto-revert-test--wait-for):
* test/lisp/net/tramp-tests.el (tramp--test-print-duration):
Prefer nil to (current-time) when either will do, as this avoids
some consing.  Similarly, prefer omitting (current-time) arg
when this is equivalent.
This commit is contained in:
Paul Eggert 2021-12-05 18:25:46 -08:00
parent af60618945
commit 524c42fa0e
13 changed files with 20 additions and 25 deletions

View file

@ -18048,7 +18048,7 @@ find all messages that have been received recently from certain groups:
(list
(cons 'query
(format-time-string "SENTSINCE %d-%b-%Y"
(time-subtract (current-time)
(time-subtract nil
(days-to-time (car args)))))
(cons 'criteria "")))
(group-spec (cadr args)))

View file

@ -314,7 +314,7 @@ This function is called, by name, directly by the C code."
(not (timer--idle-delay timer)))
(setf (timer--time timer)
(timer-next-integral-multiple-of-time
(current-time) (timer--repeat-delay timer))))
nil (timer--repeat-delay timer))))
;; Place it back on the timer-list before running
;; timer--function, so it can cancel-timer itself.
(timer-activate timer t cell)
@ -391,7 +391,7 @@ This function returns a timer object which you can use in
;; Special case: t means the next integral multiple of REPEAT.
(when (and (eq time t) repeat)
(setq time (timer-next-integral-multiple-of-time (current-time) repeat))
(setq time (timer-next-integral-multiple-of-time nil repeat))
(setf (timer--integral-multiple timer) t))
;; Handle numbers as relative times in seconds.

View file

@ -1749,7 +1749,7 @@ score in `gnus-newsgroup-scored' by SCORE."
(setq type 'after
match-func 'string<
match (gnus-time-iso8601
(time-subtract (current-time)
(time-subtract nil
(* 86400 (nth 0 kill))))))
((eq type 'before)
(setq match-func 'gnus-string>
@ -1758,7 +1758,7 @@ score in `gnus-newsgroup-scored' by SCORE."
(setq type 'before
match-func 'gnus-string>
match (gnus-time-iso8601
(time-subtract (current-time)
(time-subtract nil
(* 86400 (nth 0 kill))))))
((eq type 'at)
(setq match-func 'string=

View file

@ -572,9 +572,7 @@ REL-DATE, or (current-time) if REL-DATE is nil."
;; Time parsing doesn't seem to work with slashes.
(let ((value (string-replace "/" "-" value))
(now (append '(0 0 0)
(seq-subseq (decode-time (or rel-date
(current-time)))
3))))
(seq-subseq (decode-time rel-date) 3))))
;; Check for relative time parsing.
(if (string-match "\\([[:digit:]]+\\)\\([dwmy]\\)" value)
(seq-subseq
@ -1239,8 +1237,7 @@ nil (except that (dd nil yyyy) is not allowed). Massage those
numbers into the most recent past occurrence of whichever date
elements are present."
(pcase-let ((`(,nday ,nmonth ,nyear)
(seq-subseq (decode-time (current-time))
3 6))
(seq-subseq (decode-time) 3 6))
(`(,dday ,dmonth ,dyear) date))
(unless (and dday dmonth dyear)
(unless dday (setq dday 1))

View file

@ -3968,10 +3968,9 @@ Returns \" ? \" if there's bad input or if another error occurs.
Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
(condition-case ()
(let* ((messy-date (gnus-date-get-time messy-date))
(now (current-time))
;;If we don't find something suitable we'll use this one
(my-format "%b %d '%y"))
(let* ((difference (time-subtract now messy-date))
(let* ((difference (time-subtract nil messy-date))
(templist gnus-user-date-format-alist)
(top (eval (caar templist) t)))
(while (if (numberp top) (time-less-p top difference) (not top))
@ -10496,7 +10495,6 @@ latter case, they will be copied into the relevant groups."
"Create an article in a mail newsgroup."
(interactive nil gnus-summary-mode)
(let ((group gnus-newsgroup-name)
(now (current-time))
group-art)
(unless (gnus-check-backend-function 'request-accept-article group)
(error "%s does not support article importing" group))
@ -10506,7 +10504,7 @@ latter case, they will be copied into the relevant groups."
;; This doesn't look like an article, so we fudge some headers.
(insert "From: " (read-string "From: ") "\n"
"Subject: " (read-string "Subject: ") "\n"
"Date: " (message-make-date now) "\n"
"Date: " (message-make-date) "\n"
"Message-ID: " (message-make-message-id) "\n")
(setq group-art (gnus-request-accept-article group nil t))
(kill-buffer (current-buffer)))

View file

@ -768,7 +768,7 @@ and remove the cached thumbnail files between each trial run.")
(image-dired-debug-message
(format-time-string
"Generated thumbnails in %s.%3N seconds"
(time-subtract (current-time)
(time-subtract nil
image-dired--generate-thumbs-start))))
(if (not (and (eq (process-status process) 'exit)
(zerop (process-exit-status process))))

View file

@ -277,7 +277,7 @@ where GRAVATAR is either an image descriptor, or the symbol
;; Store the image in the cache.
(when image
(setf (gethash mail-address gravatar--cache)
(cons (time-convert (current-time) 'integer)
(cons (time-convert nil 'integer)
image)))
(prog1
(apply callback (if data image 'error) cbargs)
@ -286,7 +286,7 @@ where GRAVATAR is either an image descriptor, or the symbol
(defun gravatar--prune-cache ()
(let ((expired nil)
(time (- (time-convert (current-time) 'integer)
(time (- (time-convert nil 'integer)
;; Twelve hours.
(* 12 60 60))))
(maphash (lambda (key val)

View file

@ -2102,7 +2102,7 @@ has been handled by this function."
(interface (dbus-event-interface-name event))
(member (dbus-event-member-name event))
(arguments (dbus-event-arguments event))
(time (time-to-seconds (current-time))))
(time (float-time)))
(save-excursion
;; Check for matching method-call.
(goto-char (point-max))

View file

@ -1595,7 +1595,7 @@ If FILE-SYSTEM is non-nil, return file system attributes."
"%s" (if (or (null time)
(tramp-compat-time-equal-p time tramp-time-doesnt-exist)
(tramp-compat-time-equal-p time tramp-time-dont-know))
(current-time)
nil
time)))))
(defun tramp-gvfs-handle-get-remote-uid (vec id-format)

View file

@ -1429,7 +1429,7 @@ of."
(if (or (null time)
(tramp-compat-time-equal-p time tramp-time-doesnt-exist)
(tramp-compat-time-equal-p time tramp-time-dont-know))
(current-time)
nil
time)))
(tramp-send-command-and-check
v (format

View file

@ -534,7 +534,7 @@ the result will be a local, non-Tramp, file name."
(if (or (null time)
(tramp-compat-time-equal-p time tramp-time-doesnt-exist)
(tramp-compat-time-equal-p time tramp-time-dont-know))
(current-time)
nil
time)))
(tramp-sudoedit-send-command
v "env" "TZ=UTC" "touch" "-t"

View file

@ -127,7 +127,7 @@ This expects `auto-revert--messages' to be bound by
`ert-with-message-capture' before calling."
;; Remote files do not cooperate well with timers. So we count ourselves.
(let ((ct (current-time)))
(while (and (< (float-time (time-subtract (current-time) ct))
(while (and (< (float-time (time-subtract nil ct))
(auto-revert--timeout))
(null (string-match
(format-message
@ -167,7 +167,7 @@ This expects `auto-revert--messages' to be bound by
(defun auto-revert-tests--write-file (text file time-delta &optional append)
(write-region text nil file append 'no-message)
(set-file-times file (time-subtract (current-time) time-delta)))
(set-file-times file (time-subtract nil time-delta)))
(ert-deftest auto-revert-test00-auto-revert-mode ()
"Check autorevert for a file."
@ -453,7 +453,7 @@ This expects `auto-revert--messages' to be bound by
(defun auto-revert-test--wait-for (pred max-wait)
"Wait until PRED is true, or MAX-WAIT seconds elapsed."
(let ((ct (current-time)))
(while (and (< (float-time (time-subtract (current-time) ct)) max-wait)
(while (and (< (float-time (time-subtract nil ct)) max-wait)
(not (funcall pred)))
(read-event nil nil 0.1))))

View file

@ -241,7 +241,7 @@ is greater than 10.
(progn ,@body)
(tramp--test-message
"%s %f sec"
,message (float-time (time-subtract (current-time) start))))))
,message (float-time (time-subtract nil start))))))
;; `always' is introduced with Emacs 28.1.
(defalias 'tramp--test-always