Bug 1452202 - Clean up PLDHashTable move operator. r=froydnj, a=RyanVM
authorEric Rahm <erahm@mozilla.com>
Mon, 09 Apr 2018 11:01:59 -0700
changeset 463303 041d1c561feb5f4d9bcd492f31f7203ca477f938
parent 463302 b8c46f48908450f837506d9a03d4b50017cffc66
child 463304 1979fbb0fb9364067a2ae0bb2201166f1ef3c418
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, RyanVM
bugs1452202
milestone60.0
Bug 1452202 - Clean up PLDHashTable move operator. r=froydnj, a=RyanVM
xpcom/ds/PLDHashTable.cpp
--- a/xpcom/ds/PLDHashTable.cpp
+++ b/xpcom/ds/PLDHashTable.cpp
@@ -219,27 +219,27 @@ PLDHashTable::PLDHashTable(const PLDHash
 
 PLDHashTable&
 PLDHashTable::operator=(PLDHashTable&& aOther)
 {
   if (this == &aOther) {
     return *this;
   }
 
-  // Destruct |this|.
-  this->~PLDHashTable();
-
-  // |mOps| and |mEntrySize| are const so we can't assign them. Instead, we
-  // require that they are equal. The justification for this is that they're
+  // |mOps| and |mEntrySize| are required to stay the same, they're
   // conceptually part of the type -- indeed, if PLDHashTable was a templated
   // type like nsTHashtable, they *would* be part of the type -- so it only
   // makes sense to assign in cases where they match.
   MOZ_RELEASE_ASSERT(mOps == aOther.mOps);
   MOZ_RELEASE_ASSERT(mEntrySize == aOther.mEntrySize);
 
+  // Reconstruct |this|.
+  this->~PLDHashTable();
+  new (KnownNotNull, this) PLDHashTable(aOther.mOps, aOther.mEntrySize, 0);
+
   // Move non-const pieces over.
   mHashShift = Move(aOther.mHashShift);
   mEntryCount = Move(aOther.mEntryCount);
   mRemovedCount = Move(aOther.mRemovedCount);
   mEntryStore.Set(aOther.mEntryStore.Get(), &mGeneration);
 #ifdef DEBUG
   mChecker = Move(aOther.mChecker);
 #endif