Skip to content

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

Closed
@justingrant

Description

@justingrant

#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions