Closed
Bug 1171157
Opened 9 years ago
Closed 9 years ago
Use nested conditionals in GeckoPreferences
Categories
(Firefox for Android Graveyard :: Settings and Preferences, defect)
Tracking
(firefox42 fixed)
RESOLVED
FIXED
Firefox 42
Tracking | Status | |
---|---|---|
firefox42 | --- | fixed |
People
(Reporter: rnewman, Assigned: sergej, Mentored)
Details
(Whiteboard: [good next bug][lang=java])
Attachments
(1 file, 2 obsolete files)
12.03 KB,
patch
|
rnewman
:
review+
|
Details | Diff | Splinter Review |
GeckoPreferences has a big `if` statement like this: } else if (!AppConstants.NIGHTLY_BUILD && PREFS_LOGIN_MANAGE.equals(key)) { preferences.removePreference(pref); i--; } else if (AppConstants.RELEASE_BUILD && PREFS_DISPLAY_REFLOW_ON_ZOOM.equals(key)) { // Remove UI for reflow on release builds. preferences.removePreference(pref); i--; continue; } This has the potential to do excessive work: we check a flag *before* we check the pref string. If, say, the incoming pref is PREFS_UPDATER_AUTODOWNLOAD, but the updater is off, we'll never check the pref... and then we'll check every other clause until we run out of `if` statements! We just added one that's more expensive: } else if (PREFS_VOICE_SEARCH_ENABLED.equals(key) && (!AppConstants.NIGHTLY_BUILD || !VoiceRecognizerUtils.supportsVoiceRecognizer(getApplicationContext(), getResources()))) { // Remove UI for voice search on non nightly builds. preferences.removePreference(pref); i--; continue; } We run through this huge set of conditionals once per pref. We should consider nesting these so that we detect the pref first and short-circuit, rather than running through the entire conditional for each non-removed pref.
Reporter | ||
Comment 1•9 years ago
|
||
This would benefit from profiling when launching settings on a mid-range device. If we're spending non-trivial time in setupPreferences, we should go ahead with this bug.
Mentor: rnewman
Whiteboard: [good next bug][lang=java]
Reporter | ||
Updated•9 years ago
|
status-firefox41:
affected → ---
Assignee | ||
Comment 2•9 years ago
|
||
Attachment #8625990 -
Flags: review?(rnewman)
Reporter | ||
Comment 3•9 years ago
|
||
Comment on attachment 8625990 [details] [diff] [review] Light optimizations Review of attachment 8625990 [details] [diff] [review]: ----------------------------------------------------------------- LGTM! r+ with those duplicate parens fixed. ::: mobile/android/base/preferences/GeckoPreferences.java @@ +718,1 @@ > PREFS_TRACKING_PROTECTION_LEARN_MORE.equals(key))) { Duplicate parens. @@ +732,1 @@ > PREFS_HEALTHREPORT_LINK.equals(key))) { Duplicate parens. @@ +745,1 @@ > PREFS_GEO_LEARN_MORE.equals(key))) { Duplicate parens.
Attachment #8625990 -
Flags: review?(rnewman) → review+
Assignee | ||
Comment 4•9 years ago
|
||
Fixed those parens, plus one missed if statement
Attachment #8627657 -
Flags: review?(rnewman)
Reporter | ||
Updated•9 years ago
|
Assignee: nobody → sergej
Status: NEW → ASSIGNED
Reporter | ||
Comment 5•9 years ago
|
||
Sergej, this doesn't apply to current trunk. Could you rebase, please?
Flags: needinfo?(sergej)
Assignee | ||
Comment 6•9 years ago
|
||
Here you go, sorry for prev version.
Flags: needinfo?(sergej)
Attachment #8628047 -
Flags: review?(rnewman)
Reporter | ||
Comment 7•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=2558ca212be8
Reporter | ||
Comment 8•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/658dca224bfc
Reporter | ||
Updated•9 years ago
|
Attachment #8628047 -
Flags: review?(rnewman) → review+
Reporter | ||
Updated•9 years ago
|
Attachment #8627657 -
Attachment is obsolete: true
Attachment #8627657 -
Flags: review?(rnewman)
Reporter | ||
Updated•9 years ago
|
Attachment #8625990 -
Attachment is obsolete: true
Comment 9•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/658dca224bfc
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox42:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 42
Updated•3 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•