mirror of
https://github.com/home-assistant/frontend.git
synced 2026-07-10 15:58:17 +01:00
ce0e6a7665
formatNumberToParts, the engine behind formatNumber, built a new Intl.NumberFormat on every call. It is invoked for essentially every numeric state render, and constructing an Intl.NumberFormat is comparatively expensive. Cache the formatters in a Map keyed by (locale, options). Unlike the single-entry memoizeOne used for the date formatters, the number format options are derived per value, so a multi-entry cache is needed to avoid thrashing. The number of distinct combinations is small and bounded in practice. Output is unchanged.