Bug 1411480 - Inline and remove PREF_GetPrefType(). r=glandium.
☠☠ backed out by 3c6a28afa74b ☠ ☠
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 25 Oct 2017 10:22:38 +1100
changeset 430894 3fdf2ac7762d9656bad80e593d8b3389038109a9
parent 430893 eaa177ef5f60991f3a2ed06b50c49d3d67ea516b
child 430895 8a66ec3e83386cacc89bed3356ff0e24fefeafea
push id108
push userfmarier@mozilla.com
push dateFri, 03 Nov 2017 18:37:44 +0000
reviewersglandium
bugs1411480
milestone58.0a1
Bug 1411480 - Inline and remove PREF_GetPrefType(). r=glandium. It has a single call site. MozReview-Commit-ID: o5CwR8Od7o
modules/libpref/Preferences.cpp
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -1153,28 +1153,16 @@ pref_SizeOfPrivateData(MallocSizeOf aMal
   size_t n = gPrefNameArena.SizeOfExcludingThis(aMallocSizeOf);
   for (CallbackNode* node = gFirstCallback; node; node = node->mNext) {
     n += aMallocSizeOf(node);
     n += aMallocSizeOf(node->mDomain);
   }
   return n;
 }
 
-static PrefType
-PREF_GetPrefType(const char* aPrefName)
-{
-  if (gHashTable) {
-    PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
-    if (pref) {
-      return pref->mPrefFlags.GetPrefType();
-    }
-  }
-  return PrefType::Invalid;
-}
-
 // Bool function that returns whether or not the preference is locked and
 // therefore cannot be changed.
 static bool
 PREF_PrefIsLocked(const char* aPrefName)
 {
   bool result = false;
   if (gIsAnyPrefLocked && gHashTable) {
     PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
@@ -2310,18 +2298,27 @@ nsPrefBranch::GetRoot(char** aRoot)
   *aRoot = ToNewCString(mPrefRoot);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPrefBranch::GetPrefType(const char* aPrefName, int32_t* aRetVal)
 {
   NS_ENSURE_ARG(aPrefName);
+
   const PrefName& pref = GetPrefName(aPrefName);
-  switch (PREF_GetPrefType(pref.get())) {
+  PrefType type = PrefType::Invalid;
+  if (gHashTable) {
+    PrefHashEntry* entry = pref_HashTableLookup(pref.get());
+    if (entry) {
+      type = entry->mPrefFlags.GetPrefType();
+    }
+  }
+
+  switch (type) {
     case PrefType::String:
       *aRetVal = PREF_STRING;
       break;
 
     case PrefType::Int:
       *aRetVal = PREF_INT;
       break;