Bug 1185470: Remove 'Get' prefixes from hashtable iterator methods. r=froydnj
authorKyle Huey <khuey@kylehuey.com>
Mon, 20 Jul 2015 20:21:28 +0800
changeset 272656 d2b1e9130b6db2659661b670504e4f8d751a8b6d
parent 272655 2ba4375785977f10c702d4734088cd97b5aeb920
child 272657 f5ea755e3cb9b7fd2f56f7f453e5ea84512972c0
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-esr52@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1185470
milestone42.0a1
Bug 1185470: Remove 'Get' prefixes from hashtable iterator methods. r=froydnj
dom/media/gmp/GMPServiceParent.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
xpcom/base/SystemMemoryReporter.cpp
xpcom/base/nsConsoleService.cpp
xpcom/components/nsCategoryManager.cpp
xpcom/components/nsComponentManager.cpp
xpcom/components/nsNativeModuleLoader.cpp
xpcom/ds/nsHashPropertyBag.cpp
xpcom/ds/nsProperties.cpp
xpcom/glue/nsBaseHashtable.h
xpcom/glue/nsCategoryCache.h
xpcom/glue/nsINIParser.cpp
xpcom/reflect/xptinfo/xptiInterfaceInfoManager.cpp
xpcom/reflect/xptinfo/xptiWorkingSet.cpp
xpcom/threads/nsThreadManager.cpp
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -424,26 +424,26 @@ GeckoMediaPluginServiceParent::AsyncShut
   State* state = instances->LookupOrAdd(aInstance);
   if (!state) { return; }
   state->mStateSequence += aId;
   state->mLastStateDescription = aState;
   note += '{';
   bool firstPlugin = true;
   for (auto pluginIt = mStates.ConstIter(); !pluginIt.Done(); pluginIt.Next()) {
     if (!firstPlugin) { note += ','; } else { firstPlugin = false; }
-    note += pluginIt.GetKey();
+    note += pluginIt.Key();
     note += ":{";
     bool firstInstance = true;
-    for (auto instanceIt = pluginIt.GetData()->ConstIter(); !instanceIt.Done(); instanceIt.Next()) {
+    for (auto instanceIt = pluginIt.Data()->ConstIter(); !instanceIt.Done(); instanceIt.Next()) {
       if (!firstInstance) { note += ','; } else { firstInstance = false; }
-      note += instanceIt.GetKey();
+      note += instanceIt.Key();
       note += ":\"";
-      note += instanceIt.GetData()->mStateSequence;
+      note += instanceIt.Data()->mStateSequence;
       note += '=';
-      note += instanceIt.GetData()->mLastStateDescription;
+      note += instanceIt.Data()->mLastStateDescription;
       note += '"';
     }
     note += '}';
   }
   note += '}';
   LOGD(("%s::%s states[%s][%s]='%c'/'%s' -> %s", __CLASS__, __FUNCTION__,
         aPlugin.get(), aInstance.get(), aId, aState.get(), note.get()));
   CrashReporter::AnnotateCrashReport(
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -461,18 +461,18 @@ CycleCollectedJSRuntime::SizeOfExcluding
 
   return n;
 }
 
 void
 CycleCollectedJSRuntime::UnmarkSkippableJSHolders()
 {
   for (auto iter = mJSHolders.Iter(); !iter.Done(); iter.Next()) {
-    void* holder = iter.GetKey();
-    nsScriptObjectTracer*& tracer = iter.GetData();
+    void* holder = iter.Key();
+    nsScriptObjectTracer*& tracer = iter.Data();
     tracer->CanSkip(holder, true);
   }
 }
 
 void
 CycleCollectedJSRuntime::DescribeGCThing(bool aIsMarked, JS::GCCellPtr aThing,
                                          nsCycleCollectionTraversalCallback& aCb) const
 {
@@ -643,18 +643,18 @@ CycleCollectedJSRuntime::TraverseObjectS
 void
 CycleCollectedJSRuntime::TraverseNativeRoots(nsCycleCollectionNoteRootCallback& aCb)
 {
   // NB: This is here just to preserve the existing XPConnect order. I doubt it
   // would hurt to do this after the JS holders.
   TraverseAdditionalNativeRoots(aCb);
 
   for (auto iter = mJSHolders.Iter(); !iter.Done(); iter.Next()) {
-    void* holder = iter.GetKey();
-    nsScriptObjectTracer*& tracer = iter.GetData();
+    void* holder = iter.Key();
+    nsScriptObjectTracer*& tracer = iter.Data();
 
     bool noteRoot = false;
     if (MOZ_UNLIKELY(aCb.WantAllTraces())) {
       noteRoot = true;
     } else {
       tracer->Trace(holder,
                     TraceCallbackFunc(CheckParticipatesInCycleCollection),
                     &noteRoot);
@@ -797,18 +797,18 @@ mozilla::TraceScriptHolder(nsISupports* 
 void
 CycleCollectedJSRuntime::TraceNativeGrayRoots(JSTracer* aTracer)
 {
   // NB: This is here just to preserve the existing XPConnect order. I doubt it
   // would hurt to do this after the JS holders.
   TraceAdditionalNativeGrayRoots(aTracer);
 
   for (auto iter = mJSHolders.Iter(); !iter.Done(); iter.Next()) {
-    void* holder = iter.GetKey();
-    nsScriptObjectTracer*& tracer = iter.GetData();
+    void* holder = iter.Key();
+    nsScriptObjectTracer*& tracer = iter.Data();
     tracer->Trace(holder, JsGcTracer(), aTracer);
   }
 }
 
 void
 CycleCollectedJSRuntime::AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer)
 {
   mJSHolders.Put(aHolder, aTracer);
@@ -1018,18 +1018,18 @@ CycleCollectedJSRuntime::DumpJSHeap(FILE
 
 IncrementalFinalizeRunnable::IncrementalFinalizeRunnable(CycleCollectedJSRuntime* aRt,
                                                          DeferredFinalizerTable& aFinalizers)
   : mRuntime(aRt)
   , mFinalizeFunctionToRun(0)
   , mReleasing(false)
 {
   for (auto iter = aFinalizers.Iter(); !iter.Done(); iter.Next()) {
-    DeferredFinalizeFunction& function = iter.GetKey();
-    void*& data = iter.GetData();
+    DeferredFinalizeFunction& function = iter.Key();
+    void*& data = iter.Data();
 
     DeferredFinalizeFunctionHolder* holder =
       mDeferredFinalizeFunctions.AppendElement();
     holder->run = function;
     holder->data = data;
 
     iter.Remove();
   }
--- a/xpcom/base/SystemMemoryReporter.cpp
+++ b/xpcom/base/SystemMemoryReporter.cpp
@@ -217,18 +217,18 @@ private:
     void Add(const nsACString& aKey, size_t aSize)
     {
       mTagged.Put(aKey, mTagged.Get(aKey) + aSize);
     }
 
     void Report(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
     {
       for (auto iter = mTagged.Iter(); !iter.Done(); iter.Next()) {
-        nsCStringHashKey::KeyType key = iter.GetKey();
-        size_t amount = iter.GetUserData();
+        nsCStringHashKey::KeyType key = iter.Key();
+        size_t amount = iter.UserData();
 
         nsAutoCString path("processes/");
         path.Append(key);
 
         nsAutoCString desc("This is the sum of all processes' '");
         desc.Append(key);
         desc.AppendLiteral("' numbers.");
 
--- a/xpcom/base/nsConsoleService.cpp
+++ b/xpcom/base/nsConsoleService.cpp
@@ -335,17 +335,17 @@ nsConsoleService::LogMessageWithMode(nsI
 }
 
 void
 nsConsoleService::CollectCurrentListeners(
   nsCOMArray<nsIConsoleListener>& aListeners)
 {
   MutexAutoLock lock(mLock);
   for (auto iter = mListeners.Iter(); !iter.Done(); iter.Next()) {
-    nsIConsoleListener* value = iter.GetUserData();
+    nsIConsoleListener* value = iter.UserData();
     aListeners.AppendObject(value);
   }
 }
 
 NS_IMETHODIMP
 nsConsoleService::LogStringMessage(const char16_t* aMessage)
 {
   if (!sLoggingEnabled) {
--- a/xpcom/components/nsCategoryManager.cpp
+++ b/xpcom/components/nsCategoryManager.cpp
@@ -345,19 +345,19 @@ CategoryEnumerator::Create(nsClassHashta
   enumObj->mArray = new const char* [aTable.Count()];
   if (!enumObj->mArray) {
     delete enumObj;
     return nullptr;
   }
 
   for (auto iter = aTable.Iter(); !iter.Done(); iter.Next()) {
     // if a category has no entries, we pretend it doesn't exist
-    CategoryNode* aNode = iter.GetUserData();
+    CategoryNode* aNode = iter.UserData();
     if (aNode->Count()) {
-      const char* str = iter.GetKey();
+      const char* str = iter.Key();
       enumObj->mArray[enumObj->mCount++] = str;
     }
   }
 
   return enumObj;
 }
 
 
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -1243,17 +1243,17 @@ nsComponentManagerImpl::FreeServices()
   NS_ASSERTION(gXPCOMShuttingDown,
                "Must be shutting down in order to free all services");
 
   if (!gXPCOMShuttingDown) {
     return NS_ERROR_FAILURE;
   }
 
   for (auto iter = mFactories.Iter(); !iter.Done(); iter.Next()) {
-    nsFactoryEntry* entry = iter.GetUserData();
+    nsFactoryEntry* entry = iter.UserData();
     entry->mFactory = nullptr;
     entry->mServiceObject = nullptr;
   }
 
   return NS_OK;
 }
 
 // This should only ever be called within the monitor!
@@ -1759,30 +1759,30 @@ nsComponentManagerImpl::IsContractIDRegi
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsComponentManagerImpl::EnumerateCIDs(nsISimpleEnumerator** aEnumerator)
 {
   nsCOMArray<nsISupports> array;
   for (auto iter = mFactories.Iter(); !iter.Done(); iter.Next()) {
-    const nsID& id = iter.GetKey();
+    const nsID& id = iter.Key();
     nsCOMPtr<nsISupportsID> wrapper = new nsSupportsIDImpl();
     wrapper->SetData(&id);
     array.AppendObject(wrapper);
   }
   return NS_NewArrayEnumerator(aEnumerator, array);
 }
 
 NS_IMETHODIMP
 nsComponentManagerImpl::EnumerateContractIDs(nsISimpleEnumerator** aEnumerator)
 {
   nsTArray<nsCString>* array = new nsTArray<nsCString>;
   for (auto iter = mContractIDs.Iter(); !iter.Done(); iter.Next()) {
-    const nsACString& contract = iter.GetKey();
+    const nsACString& contract = iter.Key();
     array->AppendElement(contract);
   }
 
   nsCOMPtr<nsIUTF8StringEnumerator> e;
   nsresult rv = NS_NewAdoptingUTF8StringEnumerator(getter_AddRefs(e), array);
   if (NS_FAILED(rv)) {
     return rv;
   }
--- a/xpcom/components/nsNativeModuleLoader.cpp
+++ b/xpcom/components/nsNativeModuleLoader.cpp
@@ -192,40 +192,40 @@ nsNativeModuleLoader::LoadModule(FileLoc
 }
 
 void
 nsNativeModuleLoader::UnloadLibraries()
 {
   MOZ_ASSERT(NS_IsMainThread(), "Shutdown not on main thread?");
 
   for (auto iter = mLibraries.Iter(); !iter.Done(); iter.Next()) {
-    NativeLoadData& loadData = iter.GetData();
+    NativeLoadData& loadData = iter.Data();
     loadData.mModule = nullptr;
   }
 
   for (auto iter = mLibraries.Iter(); !iter.Done(); iter.Next()) {
     if (MOZ_LOG_TEST(GetNativeModuleLoaderLog(), LogLevel::Debug)) {
-      nsIHashable* hashedFile = iter.GetKey();
+      nsIHashable* hashedFile = iter.Key();
       nsCOMPtr<nsIFile> file(do_QueryInterface(hashedFile));
 
       nsAutoCString filePath;
       file->GetNativePath(filePath);
 
       LOG(LogLevel::Debug,
           ("nsNativeModuleLoader::UnloaderFunc(\"%s\")", filePath.get()));
     }
 
 #ifdef NS_BUILD_REFCNT_LOGGING
     nsTraceRefcnt::SetActivityIsLegal(false);
 #endif
 
 #if 0
     // XXXbsmedberg: do this as soon as the static-destructor crash(es)
     // are fixed
-    NativeLoadData& loadData = iter.GetData();
+    NativeLoadData& loadData = iter.Data();
     PRStatus ret = PR_UnloadLibrary(loadData.mLibrary);
     NS_ASSERTION(ret == PR_SUCCESS, "Failed to unload library");
 #endif
 
 #ifdef NS_BUILD_REFCNT_LOGGING
     nsTraceRefcnt::SetActivityIsLegal(true);
 #endif
 
--- a/xpcom/ds/nsHashPropertyBag.cpp
+++ b/xpcom/ds/nsHashPropertyBag.cpp
@@ -118,18 +118,18 @@ NS_IMETHODIMP
 nsHashPropertyBagBase::GetEnumerator(nsISimpleEnumerator** aResult)
 {
   nsCOMPtr<nsIMutableArray> propertyArray = nsArray::Create();
   if (!propertyArray) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   for (auto iter = mPropertyHash.Iter(); !iter.Done(); iter.Next()) {
-    const nsAString& key = iter.GetKey();
-    nsIVariant* data = iter.GetUserData();
+    const nsAString& key = iter.Key();
+    nsIVariant* data = iter.UserData();
     nsSimpleProperty* sprop = new nsSimpleProperty(key, data);
     propertyArray->AppendElement(sprop, false);
   }
 
   return NS_NewArrayEnumerator(aResult, propertyArray);
 }
 
 #define IMPL_GETSETPROPERTY_AS(Name, Type) \
--- a/xpcom/ds/nsProperties.cpp
+++ b/xpcom/ds/nsProperties.cpp
@@ -72,17 +72,17 @@ nsProperties::GetKeys(uint32_t* aCount, 
     return NS_ERROR_INVALID_ARG;
   }
 
   uint32_t count = Count();
   char** keys = (char**)moz_xmalloc(count * sizeof(char*));
   uint32_t j = 0;
 
   for (auto iter = this->Iter(); !iter.Done(); iter.Next()) {
-    const char* key = iter.GetKey();
+    const char* key = iter.Key();
     keys[j] = strdup(key);
 
     if (!keys[j]) {
       // Free 'em all
       for (uint32_t i = 0; i < j; i++) {
         free(keys[i]);
       }
       free(keys);
--- a/xpcom/glue/nsBaseHashtable.h
+++ b/xpcom/glue/nsBaseHashtable.h
@@ -218,39 +218,39 @@ public:
       }
     }
     return n;
   }
 
   // This is an iterator that also allows entry removal. Example usage:
   //
   //   for (auto iter = table.Iter(); !iter.Done(); iter.Next()) {
-  //     const KeyType key = iter.GetKey();
-  //     const UserDataType data = iter.GetUserData();
+  //     const KeyType key = iter.Key();
+  //     const UserDataType data = iter.UserData();
   //     // or
-  //     const DataType& data = iter.GetData();
+  //     const DataType& data = iter.Data();
   //     // ... do stuff with |key| and/or |data| ...
   //     // ... possibly call iter.Remove() once ...
   //   }
   //
   class Iterator : public PLDHashTable::Iterator
   {
   public:
     typedef PLDHashTable::Iterator Base;
 
     explicit Iterator(nsBaseHashtable* aTable) : Base(&aTable->mTable) {}
     Iterator(Iterator&& aOther) : Base(aOther.mTable) {}
     ~Iterator() {}
 
-    KeyType GetKey() const { return static_cast<EntryType*>(Get())->GetKey(); }
-    UserDataType GetUserData() const
+    KeyType Key() const { return static_cast<EntryType*>(Get())->GetKey(); }
+    UserDataType UserData() const
     {
       return static_cast<EntryType*>(Get())->mData;
     }
-    DataType& GetData() const { return static_cast<EntryType*>(Get())->mData; }
+    DataType& Data() const { return static_cast<EntryType*>(Get())->mData; }
 
   private:
     Iterator() = delete;
     Iterator(const Iterator&) = delete;
     Iterator& operator=(const Iterator&) = delete;
     Iterator& operator=(const Iterator&&) = delete;
   };
 
--- a/xpcom/glue/nsCategoryCache.h
+++ b/xpcom/glue/nsCategoryCache.h
@@ -71,17 +71,17 @@ public:
   {
     // Lazy initialization, so that services in this category can't
     // cause reentrant getService (bug 386376)
     if (!mObserver) {
       mObserver = new nsCategoryObserver(mCategoryName.get());
     }
 
     for (auto iter = mObserver->GetHash().Iter(); !iter.Done(); iter.Next()) {
-      nsISupports* entry = iter.GetUserData();
+      nsISupports* entry = iter.UserData();
       nsCOMPtr<T> service = do_QueryInterface(entry);
       if (service) {
         aResult.AppendObject(service);
       }
     }
   }
 
 private:
--- a/xpcom/glue/nsINIParser.cpp
+++ b/xpcom/glue/nsINIParser.cpp
@@ -298,17 +298,17 @@ nsINIParser::GetString(const char* aSect
 
   return NS_ERROR_FAILURE;
 }
 
 nsresult
 nsINIParser::GetSections(INISectionCallback aCB, void* aClosure)
 {
   for (auto iter = mSections.Iter(); !iter.Done(); iter.Next()) {
-    if (!aCB(iter.GetKey(), aClosure)) {
+    if (!aCB(iter.Key(), aClosure)) {
       break;
     }
   }
   return NS_OK;
 }
 
 nsresult
 nsINIParser::GetStrings(const char* aSection,
--- a/xpcom/reflect/xptinfo/xptiInterfaceInfoManager.cpp
+++ b/xpcom/reflect/xptinfo/xptiInterfaceInfoManager.cpp
@@ -267,17 +267,17 @@ XPTInterfaceInfoManager::GetScriptableIn
     // I didn't want to incur the size overhead of using nsHashtable just to
     // make building an enumerator easier. So, this code makes a snapshot of
     // the table using an nsISupportsArray and builds an enumerator for that.
     // We can afford this transient cost.
 
     ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
     aInterfaces.SetCapacity(mWorkingSet.mNameTable.Count());
     for (auto iter = mWorkingSet.mNameTable.Iter(); !iter.Done(); iter.Next()) {
-        xptiInterfaceEntry* entry = iter.GetUserData();
+        xptiInterfaceEntry* entry = iter.UserData();
         if (entry->GetScriptableFlag()) {
             nsCOMPtr<nsIInterfaceInfo> ii = entry->InterfaceInfo();
             aInterfaces.AppendElement(ii);
         }
     }
 }
 
 /* nsIEnumerator enumerateInterfacesWhoseNamesStartWith (in string prefix); */
@@ -287,17 +287,17 @@ XPTInterfaceInfoManager::EnumerateInterf
     nsCOMPtr<nsISupportsArray> array;
     NS_NewISupportsArray(getter_AddRefs(array));
     if (!array)
         return NS_ERROR_UNEXPECTED;
 
     ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
     uint32_t length = static_cast<uint32_t>(strlen(prefix));
     for (auto iter = mWorkingSet.mNameTable.Iter(); !iter.Done(); iter.Next()) {
-        xptiInterfaceEntry* entry = iter.GetUserData();
+        xptiInterfaceEntry* entry = iter.UserData();
         const char* name = entry->GetTheName();
         if (name != PL_strnstr(name, prefix, length)) {
             continue;
         }
         nsCOMPtr<nsIInterfaceInfo> ii;
         if (NS_SUCCEEDED(EntryToInfo(entry, getter_AddRefs(ii)))) {
             array->AppendElement(ii);
         }
--- a/xpcom/reflect/xptinfo/xptiWorkingSet.cpp
+++ b/xpcom/reflect/xptinfo/xptiWorkingSet.cpp
@@ -27,17 +27,17 @@ XPTInterfaceInfoManager::xptiWorkingSet:
                                     "xptiWorkingSet structs");
 }
 
 void
 XPTInterfaceInfoManager::xptiWorkingSet::InvalidateInterfaceInfos()
 {
     ReentrantMonitorAutoEnter monitor(mTableReentrantMonitor);
     for (auto iter = mNameTable.Iter(); !iter.Done(); iter.Next()) {
-        xptiInterfaceEntry* entry = iter.GetUserData();
+        xptiInterfaceEntry* entry = iter.UserData();
         entry->LockedInvalidateInterfaceInfo();
     }
 }
 
 XPTInterfaceInfoManager::xptiWorkingSet::~xptiWorkingSet()
 {
     MOZ_COUNT_DTOR(xptiWorkingSet);
 
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -127,17 +127,17 @@ nsThreadManager::Shutdown()
   NS_ProcessPendingEvents(mMainThread);
 
   // We gather the threads from the hashtable into a list, so that we avoid
   // holding the hashtable lock while calling nsIThread::Shutdown.
   nsThreadArray threads;
   {
     OffTheBooksMutexAutoLock lock(mLock);
     for (auto iter = mThreadsByPRThread.Iter(); !iter.Done(); iter.Next()) {
-      nsRefPtr<nsThread>& thread = iter.GetData();
+      nsRefPtr<nsThread>& thread = iter.Data();
       threads.AppendElement(thread);
       iter.Remove();
     }
   }
 
   // It's tempting to walk the list of threads here and tell them each to stop
   // accepting new events, but that could lead to badness if one of those
   // threads is stuck waiting for a response from another thread.  To do it