emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 524c42f 04/13: Prefer nil to (current-time) when either will do


From: Paul Eggert
Subject: master 524c42f 04/13: Prefer nil to (current-time) when either will do
Date: Mon, 6 Dec 2021 02:24:21 -0500 (EST)

branch: master
commit 524c42fa0eb9e4bf02d39e4d04353a354a84cebc
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    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.
---
 doc/misc/gnus.texi            | 2 +-
 lisp/emacs-lisp/timer.el      | 4 ++--
 lisp/gnus/gnus-score.el       | 4 ++--
 lisp/gnus/gnus-search.el      | 7 ++-----
 lisp/gnus/gnus-sum.el         | 6 ++----
 lisp/image-dired.el           | 2 +-
 lisp/image/gravatar.el        | 4 ++--
 lisp/net/dbus.el              | 2 +-
 lisp/net/tramp-gvfs.el        | 2 +-
 lisp/net/tramp-sh.el          | 2 +-
 lisp/net/tramp-sudoedit.el    | 2 +-
 test/lisp/autorevert-tests.el | 6 +++---
 test/lisp/net/tramp-tests.el  | 2 +-
 13 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 6ffc057..74b5fb4 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -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)))
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index 2ac2c99..c7d02cc 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -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.
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index d031047..a25673a 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -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=
diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el
index c77de68..a79c106 100644
--- a/lisp/gnus/gnus-search.el
+++ b/lisp/gnus/gnus-search.el
@@ -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))
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index dcdf3d9..ba61658 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -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)))
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 0723804..fe0c3b7 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -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))))
diff --git a/lisp/image/gravatar.el b/lisp/image/gravatar.el
index f6f056a..87726a9 100644
--- a/lisp/image/gravatar.el
+++ b/lisp/image/gravatar.el
@@ -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)
diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el
index 3fff539..4112497 100644
--- a/lisp/net/dbus.el
+++ b/lisp/net/dbus.el
@@ -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))
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 22e3142..6d83ae5 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -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)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 8d10659..8e66363 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -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
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
index c91bced..6da00f8 100644
--- a/lisp/net/tramp-sudoedit.el
+++ b/lisp/net/tramp-sudoedit.el
@@ -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"
diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el
index b9d4532..b31f0a9 100644
--- a/test/lisp/autorevert-tests.el
+++ b/test/lisp/autorevert-tests.el
@@ -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))))
 
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 47fa18e..c047f66 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]