-
Notifications
You must be signed in to change notification settings - Fork 760
Closed
Closed
Copy link
Labels
Description
I'm profiling a calendar page which shows a bunch of events. I collect a profiling file and open it in https://www.speedscope.app, look at sandwich view, and see that isEnglish
is the 3th slowest function (by self time) (and supportsFastNumbers is 5th):
I take a look at isEnglish
:
Lines 479 to 485 in 0702328
isEnglish() { | |
return ( | |
this.locale === "en" || | |
this.locale.toLowerCase() === "en-us" || | |
new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us") | |
); | |
} |
As I'm working in Norwegian locale, I assume this returns false, but most importantly - creates new Intl.DateTimeFormat
on every call.
I have not tried this yet, but I believe we can win some time if we cache Intl.DateTimeFormat
(or avoid doing this check).
Same happens in supportsFastNumbers
.
- OS: Win 11
- Browser: Chrome 112.0.5615.138
- Luxon: 3.3.0