mirror of
https://github.com/home-assistant/frontend.git
synced 2026-09-27 12:03:51 +01:00
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.