Bug 1376498 part 3 - Make nsClassHashtable inherit Remove() for API consistency with ns[Base|Interface|RefPtr]Hashtable. r=froydnj
authorMats Palmgren <mats@mozilla.com>
Wed, 05 Jul 2017 02:01:44 +0200
changeset 367342 29730c843219f7d2342bb1c5aa43be19c005eb94
parent 367341 d46d1d8506ad2e87db24da457da24722810a3e1b
child 367343 512c69e35fc0c7b3414a7644f825be1eb4ee1beb
push id32130
push usercbook@mozilla.com
push dateWed, 05 Jul 2017 11:01:49 +0000
treeherdermozilla-central@211d4dd61025 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1376498
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1376498 part 3 - Make nsClassHashtable inherit Remove() for API consistency with ns[Base|Interface|RefPtr]Hashtable. r=froydnj MozReview-Commit-ID: LQMaamZhkM4
xpcom/ds/nsClassHashtable.h
--- a/xpcom/ds/nsClassHashtable.h
+++ b/xpcom/ds/nsClassHashtable.h
@@ -25,16 +25,17 @@ class nsClassHashtable
   : public nsBaseHashtable<KeyClass, nsAutoPtr<T>, T*>
 {
 public:
   typedef typename KeyClass::KeyType KeyType;
   typedef T* UserDataType;
   typedef nsBaseHashtable<KeyClass, nsAutoPtr<T>, T*> base_type;
 
   using base_type::IsEmpty;
+  using base_type::Remove;
 
   nsClassHashtable() {}
   explicit nsClassHashtable(uint32_t aInitLength)
     : nsBaseHashtable<KeyClass, nsAutoPtr<T>, T*>(aInitLength)
   {
   }
 
   /**
@@ -51,28 +52,20 @@ public:
   bool Get(KeyType aKey, UserDataType* aData) const;
 
   /**
    * @copydoc nsBaseHashtable::Get
    * @returns nullptr if the key is not present.
    */
   UserDataType Get(KeyType aKey) const;
 
-  /**
-   * Remove the entry for the given key from the hashtable and return it in
-   * aOut.  If the key is not in the hashtable, aOut's pointer is set to
-   * nullptr.
-   *
-   * Normally, an entry is deleted when it's removed from an nsClassHashtable,
-   * but this function transfers ownership of the entry back to the caller
-   * through aOut -- the entry will be deleted when aOut goes out of scope.
-   *
-   * @param aKey the key to get and remove from the hashtable
-   */
-  void RemoveAndForget(KeyType aKey, nsAutoPtr<T>& aOut);
+  // obsolete - will be removed after converting existing consumers to Remove.
+  void RemoveAndForget(KeyType aKey, nsAutoPtr<T>& aOut) {
+    Remove(aKey, &aOut);
+  }
 };
 
 //
 // nsClassHashtable definitions
 //
 
 template<class KeyClass, class T>
 template<typename... Args>
@@ -116,26 +109,9 @@ nsClassHashtable<KeyClass, T>::Get(KeyTy
   typename base_type::EntryType* ent = this->GetEntry(aKey);
   if (!ent) {
     return nullptr;
   }
 
   return ent->mData;
 }
 
-template<class KeyClass, class T>
-void
-nsClassHashtable<KeyClass, T>::RemoveAndForget(KeyType aKey, nsAutoPtr<T>& aOut)
-{
-  aOut = nullptr;
-
-  typename base_type::EntryType* ent = this->GetEntry(aKey);
-  if (!ent) {
-    return;
-  }
-
-  // Transfer ownership from ent->mData into aOut.
-  aOut = mozilla::Move(ent->mData);
-
-  this->RemoveEntry(ent);
-}
-
 #endif // nsClassHashtable_h__