Bug 1120198 part 1 - Introduce nsTHashtable::SwapElements for a fast way to swap the elements of two hashtables. r=nfroyd

This commit is contained in:
Mats Palmgren 2015-01-13 14:44:33 +00:00
parent bab8720286
commit 68aa3fcdaa

View File

@ -10,6 +10,7 @@
#include "nscore.h"
#include "pldhash.h"
#include "nsDebug.h"
#include "mozilla/Assertions.h"
#include "mozilla/MemoryChecking.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Move.h"
@ -289,6 +290,16 @@ public:
return SizeOfIncludingThis(BasicSizeOfEntryExcludingThisFun, aMallocSizeOf);
}
/**
* Swap the elements in this hashtable with the elements in aOther.
*/
void SwapElements(nsTHashtable<EntryType>& aOther)
{
MOZ_ASSERT_IF(this->mTable.ops && aOther.mTable.ops,
this->mTable.ops == aOther.mTable.ops);
mozilla::Swap(this->mTable, aOther.mTable);
}
#ifdef DEBUG
/**
* Mark the table as constant after initialization.