Closed Bug 2004793 Opened 10 months ago Closed 5 months ago

getSelectedLocale spends time sorting locales unnecessarily

Categories

(Firefox for Android :: General, task)

All
Android
task

Tracking

()

RESOLVED FIXED
152 Branch
Tracking Status
firefox152 --- fixed

People

(Reporter: mstange, Assigned: kaya)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [group6][fenix-applink][fxdroid])

Attachments

(1 file, 1 obsolete file)

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 the locale returned from getCurrentLocale is one of the supported locales.

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
Assignee: nobody → mstange.moz
Status: NEW → ASSIGNED

Triage: adding the whiteboard label for tracking.

Adding the label because locale querying affects the pocket config which affects the homepage.

Whiteboard: [group6][fenix-applink]

The Bugbug bot thinks this bug should belong to the 'Firefox for Android::Tooling' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: General → Tooling

You think everything is tooling, BugBot.

Component: Tooling → General

The severity field is not set for this bug.
:polly, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(polly)
Severity: -- → S4
Type: defect → task
Flags: needinfo?(polly)
Blocks: 2009369
Whiteboard: [group6][fenix-applink] → [group6][fenix-applink][fxdroid]
Blocks: 2030340
No longer blocks: 2009369
Assignee: mstange.moz → kkaya
Pushed by kkaya@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/2332044db7b9 https://hg.mozilla.org/integration/autoland/rev/eccb019b8cb2 Avoid recreating ICU locale objects in getSelectedLocale by checking language tags directly. r=android-reviewers,nalexander
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch
Attachment #9533496 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: