Migrating to Swift Duration

This looks alright to me. Perhaps multiply by 1e-18 instead of division, although I am not sure if this is any faster (in the past division was much slower than multiplication but these days?). Swift compiler doesn't change "/ 1e18" to "* 1e-18" (perhaps it should if multiplication is faster?).

Pedantically speaking conversion from TimeInterval to Duration is also lossy (considering durations shorter than 1e-18 or longer than 1e+19).

I was wondering about a similar thing before.

1 Like