You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
utils: $utils.date.format makes a new Intl.DateTimeFormat on each call #62
$utils.date.format(value, options) in packages/bongo/src/utils/config.ts makes a new Intl.DateTimeFormat on each call that has options. Making a formatter is slow. On Bun 1.4.3 (M1 Max), 20,000 calls with { dateStyle: 'long' } take 570 ms. One shared formatter takes 10 ms for the same 20,000 dates.
A site that shows a date on each of its 10,000 pages, and again in its lists, pays this on each build. The bench site of #56 had the same pattern in its own $utils; one shared formatter saved about 0.4 s of its build.
Direction
Keep a formatter for each $site.lang and set of options. Make the key from the options with their keys sorted. Limit the cache size, because the options can come from content.
Acceptance
Each call returns the same text as before.
A test covers two calls with the same options in a different key order.
Activity
perf: cache date formatters
perf: cache date formatters