Open Bug 2004793 Opened 1 day ago Updated 1 day ago

getSelectedLocale spends time sorting locales unnecessarily

Categories

(Firefox for Android :: General, defect)

All
Android
defect

Tracking

()

People

(Reporter: mstange, Unassigned)

References

(Blocks 1 open bug)

Details

Profile: https://share.firefox.dev/48FzHrj

When we call getSelectedLocale during the initialization of the pocket stories service, we spend an unnecessary amount of time building a sorted list of the supported locales, just so that we can check whether getCurrentLocale returns a supported locale.

I believe we could just check getCurrentLocale's language tag against the language tags in SUPPORTED_LOCALE_ARRAY instead.

The sorting is slow because the displayLanguage and displayCountry accessors don't cache the ICU locale object, so those internal C++ objects get recreated for every comparison performed during the sort.

Blocks: 2003950
You need to log in before you can comment on or make changes to this bug.