Skip to content

Commit cbbdfc2

Browse files
authored
CORE: optimize time formatting, fix typo and wrong comment (#371)
'apply' is usually less effective as a direct call. For frequently called code this counts. Therefore we write better dispatch on tz0 with a test - see #371 for details.
1 parent 9957d97 commit cbbdfc2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/ln_core/time.scm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ end-of-c-declare
554554

555555
(define (time-utc->time-monotonic! time-in)
556556
(if (not (eq? (srfi19:time-type time-in) time-utc))
557-
(tm:time-error 'time-utc->time-montonic! 'incompatible-time-types time-in))
557+
(tm:time-error 'time-utc->time-monotonic! 'incompatible-time-types time-in))
558558
(let ((ntime (tm:time-utc->time-tai! time-in time-in
559559
'time-utc->time-monotonic!)))
560560
(srfi19:time-type-set! ntime time-monotonic)
@@ -1514,9 +1514,10 @@ end-of-c-declare
15141514
)
15151515
utc2))
15161516

1517-
;; can't do optimization here as tz0 is needed later
15181517
(define (string->seconds str fmt . tz0)
1519-
(apply string->seconds~ (append (list str (ln:tildify fmt)) tz0)))
1518+
(if (pair? tz0)
1519+
(string->seconds~ str (ln:tildify fmt) (car tz0))
1520+
(string->seconds~ str (ln:tildify fmt))))
15201521

15211522
(define (seconds->string~ sec0 fmt tz)
15221523
(let* ((sec (+ sec0 (* tz 3600.)))

0 commit comments

Comments
 (0)