haskell-github-trust / thyme

A faster date and time library based on time
BSD 3-Clause "New" or "Revised" License
46 stars 33 forks source link

Make `ordinalDate` more efficient #25

Closed klao closed 10 years ago

klao commented 10 years ago

For fromOrdinalDate the change is trivial: just using bit shifts instead of dividing by 4.

For toOrdinalDate we do a completely different computation, which requires (about) 2 divisions instead of 4.

Also adding appropriate benchmarks and tests, and making the tests a bit more thorough (100 iterations is not enough to catch subtle bugs).

liyang commented 10 years ago

(Apologies) I've chopped your commits up and shuffled them around a little, but they're basically picked. Thanks!

(Further apologies for my tardiness…)