From 5bd6074415e8d572931ee51112d9b70b70e2ba55 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 19 Dec 2018 12:57:25 -0800 Subject: Minor fixes/simplifications to time functions * doc/lispintro/emacs-lisp-intro.texi (Files List): Simplify. * doc/lispref/os.texi (Time of Day): Mention format-time-string as an alternative to current-time-string. * lisp/arc-mode.el (archive-unixdate, archive-unixtime): Port better to future versions of Emacs where (COUNT . HZ) will take precedence to (HI . LO). * lisp/arc-mode.el (archive-unixtime): * lisp/calendar/todo-mode.el (todo-insert-item--basic) (todo-item-done, todo-read-time): Prefer format-time-string to substringing current-time-string. * lisp/calc/calc-forms.el (calc-time, calcFunc-now): Prefer decode-time to parsing the output of current-time-string. * lisp/emacs-lisp/cl-extra.el (cl--random-time): Prefer encode-time to hashing the output of current-time-string. * lisp/gnus/gnus-score.el (gnus-score-headers) (gnus-score-adaptive): Avoid stringifying and then reparsing timestamp. * src/timefns.c (Fencode_time): Omit redundant assignment. --- lisp/emacs-lisp/cl-extra.el | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el index 13988db9a86..78484fcfa3f 100644 --- a/lisp/emacs-lisp/cl-extra.el +++ b/lisp/emacs-lisp/cl-extra.el @@ -438,9 +438,7 @@ as an integer unless JUNK-ALLOWED is non-nil." ;; Random numbers. (defun cl--random-time () - (let* ((time (copy-sequence (current-time-string))) (i (length time)) (v 0)) - (while (>= (cl-decf i) 0) (setq v (+ (* v 3) (aref time i)))) - v)) + (car (encode-time nil t))) ;;;###autoload (autoload 'cl-random-state-p "cl-extra") (cl-defstruct (cl--random-state -- cgit v1.2.3