Bug 1559563 - P2. Small optimization of `Once` StaticPrefs accessor. 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
This commit is contained in:
Jean-Yves Avenard 2019-06-18 11:26:25 +00:00
Родитель b10113a9fc
Коммит 624887abc5
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -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;
}
@ -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