Bug 440908 - Remove gIsAnyPrefLocked. r=glandium draft
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 05 Mar 2018 15:18:34 +1100
changeset 763483 cb7ea3f90bf89734f76e7d5b3e992fc82c92b178
parent 763108 99fd2c41687b7a9f7912a2b74b1eaaf4fa7a96f9
child 763484 ec4ed3a0a8190164725d65d62c7b3e5272d32b68
push id101468
push usernnethercote@mozilla.com
push dateTue, 06 Mar 2018 02:40:44 +0000
reviewersglandium
bugs440908
milestone60.0a1
Bug 440908 - Remove gIsAnyPrefLocked. r=glandium It optimizes Preferences::IsLocked(), but that function is called fewer than 200 times while starting the browser and opening a range of tabs. MozReview-Commit-ID: 5q0zS8TSwdu
modules/libpref/Preferences.cpp
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -815,18 +815,16 @@ private:
 
 static PLDHashTable* gHashTable;
 
 // The callback list contains all the priority callbacks followed by the
 // non-priority callbacks. gLastPriorityNode records where the first part ends.
 static CallbackNode* gFirstCallback = nullptr;
 static CallbackNode* gLastPriorityNode = nullptr;
 
-static bool gIsAnyPrefLocked = false;
-
 // These are only used during the call to NotifyCallbacks().
 static bool gCallbacksInProgress = false;
 static bool gShouldCleanupDeadNodes = false;
 
 static PLDHashTableOps pref_HashTableOps = {
   PLDHashTable::HashStringKey, PrefEntry::MatchEntry,
   PLDHashTable::MoveEntryStub, PrefEntry::ClearEntry,
   PrefEntry::InitEntry,
@@ -4180,17 +4178,16 @@ Preferences::LockInAnyProcess(const char
 
   Pref* pref = pref_HashTableLookup(aPrefName);
   if (!pref) {
     return NS_ERROR_UNEXPECTED;
   }
 
   if (!pref->IsLocked()) {
     pref->SetIsLocked(true);
-    gIsAnyPrefLocked = true;
     NotifyCallbacks(aPrefName);
   }
 
   return NS_OK;
 }
 
 /* static */ nsresult
 Preferences::Lock(const char* aPrefName)
@@ -4218,24 +4215,18 @@ Preferences::Unlock(const char* aPrefNam
   return NS_OK;
 }
 
 /* static */ bool
 Preferences::IsLocked(const char* aPrefName)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), false);
 
-  if (gIsAnyPrefLocked) {
-    Pref* pref = pref_HashTableLookup(aPrefName);
-    if (pref && pref->IsLocked()) {
-      return true;
-    }
-  }
-
-  return false;
+  Pref* pref = pref_HashTableLookup(aPrefName);
+  return pref && pref->IsLocked();
 }
 
 /* static */ nsresult
 Preferences::ClearUserInAnyProcess(const char* aPrefName)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
 
   PrefEntry* entry = pref_HashTableLookupInner(aPrefName);