LycheeOrg / Lychee-front

JS implementation of Lychee frontend
https://lycheeorg.github.io/
MIT License
48 stars 53 forks source link

Improve performance of time localization #333

Closed nagmat84 closed 2 years ago

nagmat84 commented 2 years ago

While I have been working on some other PRs I noticed that for 5% of the runtime for layouting large albums listings was spent for localization of the date/time.

For each album/photo the JS engine built a DateTimeFormat object internally when Date::toLocaleString was called. This PR swaps it. The DateTimeFormat object is only built once globally, and then we use DateTimeFormat::format(date) to localize the date.