Commit 845b5c3e authored by Paul Eggert's avatar Paul Eggert
Browse files

* play/hanoi.el (hanoi-current-time-float): Remove.

All uses replaced by float-time.
parent ee6f1be0
2011-07-01 Paul Eggert <eggert@cs.ucla.edu> 2011-07-01 Paul Eggert <eggert@cs.ucla.edu>
* play/hanoi.el (hanoi-current-time-float): Remove.
All uses replaced by float-time.
* nxml/rng-maint.el (rng-time-function): Rewrite using time-subtract. * nxml/rng-maint.el (rng-time-function): Rewrite using time-subtract.
This yields a more-accurate answer. This yields a more-accurate answer.
(rng-time-to-float): Remove; no longer needed. (rng-time-to-float): Remove; no longer needed.
......
...@@ -113,7 +113,7 @@ intermediate positions." ...@@ -113,7 +113,7 @@ intermediate positions."
(prefix-numeric-value current-prefix-arg)))) (prefix-numeric-value current-prefix-arg))))
(if (< nrings 0) (if (< nrings 0)
(error "Negative number of rings")) (error "Negative number of rings"))
(hanoi-internal nrings (make-list nrings 0) (hanoi-current-time-float))) (hanoi-internal nrings (make-list nrings 0) (float-time)))
;;;###autoload ;;;###autoload
(defun hanoi-unix () (defun hanoi-unix ()
...@@ -123,7 +123,7 @@ second since 1970-01-01 00:00:00 GMT. ...@@ -123,7 +123,7 @@ second since 1970-01-01 00:00:00 GMT.
Repent before ring 31 moves." Repent before ring 31 moves."
(interactive) (interactive)
(let* ((start (ftruncate (hanoi-current-time-float))) (let* ((start (ftruncate (float-time)))
(bits (loop repeat 32 (bits (loop repeat 32
for x = (/ start (expt 2.0 31)) then (* x 2.0) for x = (/ start (expt 2.0 31)) then (* x 2.0)
collect (truncate (mod x 2.0)))) collect (truncate (mod x 2.0))))
...@@ -137,7 +137,7 @@ This is, necessarily (as of Emacs 20.3), a crock. When the ...@@ -137,7 +137,7 @@ This is, necessarily (as of Emacs 20.3), a crock. When the
current-time interface is made s2G-compliant, hanoi.el will need current-time interface is made s2G-compliant, hanoi.el will need
to be updated." to be updated."
(interactive) (interactive)
(let* ((start (ftruncate (hanoi-current-time-float))) (let* ((start (ftruncate (float-time)))
(bits (loop repeat 64 (bits (loop repeat 64
for x = (/ start (expt 2.0 63)) then (* x 2.0) for x = (/ start (expt 2.0 63)) then (* x 2.0)
collect (truncate (mod x 2.0)))) collect (truncate (mod x 2.0))))
...@@ -283,11 +283,6 @@ BITS must be of length nrings. Start at START-TIME." ...@@ -283,11 +283,6 @@ BITS must be of length nrings. Start at START-TIME."
(setq buffer-read-only t) (setq buffer-read-only t)
(force-mode-line-update))) (force-mode-line-update)))
(defun hanoi-current-time-float ()
"Return values from current-time combined into a single float."
(destructuring-bind (high low micros) (current-time)
(+ (* high 65536.0) low (/ micros 1000000.0))))
(defun hanoi-put-face (start end value &optional object) (defun hanoi-put-face (start end value &optional object)
"If hanoi-use-faces is non-nil, call put-text-property for face property." "If hanoi-use-faces is non-nil, call put-text-property for face property."
(if hanoi-use-faces (if hanoi-use-faces
...@@ -383,7 +378,7 @@ BITS must be of length nrings. Start at START-TIME." ...@@ -383,7 +378,7 @@ BITS must be of length nrings. Start at START-TIME."
(/ (- tick flyward-ticks fly-ticks) (/ (- tick flyward-ticks fly-ticks)
ticks-per-pole-step)))))))) ticks-per-pole-step))))))))
(if hanoi-move-period (if hanoi-move-period
(loop for elapsed = (- (hanoi-current-time-float) start-time) (loop for elapsed = (- (float-time) start-time)
while (< elapsed hanoi-move-period) while (< elapsed hanoi-move-period)
with tick-period = (/ (float hanoi-move-period) total-ticks) with tick-period = (/ (float hanoi-move-period) total-ticks)
for tick = (ceiling (/ elapsed tick-period)) do for tick = (ceiling (/ elapsed tick-period)) do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment