Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider caching and/or lazy-init of DateTimeFormat instances in intl.mjs #9

Closed
justingrant opened this issue Jul 9, 2021 · 1 comment

Comments

@justingrant
Copy link
Contributor

#7 and #8 showed that new DateTimeFormat() is astoundingly expensive in time and memory. Big perf wins come from caching these instances.

The constructor for DateTimeFormat in this polyfill (which is called in every toLocaleString call) calls the builtin Intl.DateTimeFormat constructor 8 times. This will be slooooooooooow.

All those instances are probably unnecessary. At a minimum, we should lazy-init these instances so they're only constructed when needed. Given that users typically re-use the same options over and over, we could also consider caching DateTimeFormat instances too.

@justingrant
Copy link
Contributor Author

justingrant commented Jul 16, 2021

Fixed by #12. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant