Skip to content

Commit

Permalink
Bug 1559563 - P2. Small optimization of Once StaticPrefs accessor. …
Browse files Browse the repository at this point in the history
…r=njn

We can avoid testing if we are running in the parent process.

Differential Revision: https://phabricator.services.mozilla.com/D35125

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Jean-Yves Avenard committed Jun 18, 2019
1 parent b10113a commit 624887a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/libpref/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5395,8 +5395,9 @@ static void InitVarCachePref(StaticPrefs::UpdatePolicy aPolicy,
static Atomic<bool> sOncePrefRead(false);
static StaticMutex sOncePrefMutex;

/* static */ void StaticPrefs::MaybeInitOncePrefs() {
if (!XRE_IsParentProcess() || sOncePrefRead) {
/* static */
void StaticPrefs::MaybeInitOncePrefs() {
if (MOZ_LIKELY(sOncePrefRead)) {
// `Once` StaticPrefs have already been initialized to their default value.
return;
}
Expand Down Expand Up @@ -5676,6 +5677,10 @@ void StaticPrefs::InitStaticPrefsFromShared() {
#include "mozilla/StaticPrefList.h"
#undef PREF
#undef VARCACHE_PREF
// `Once` StaticPrefs have been set to their value in the step above and
// outside the parent process they are immutable. So we set sOncePrefRead
// so that we can directly skip any lazy initializations.
sOncePrefRead = true;
}

} // namespace mozilla
Expand Down

0 comments on commit 624887a

Please sign in to comment.