mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1168007 (part 6) - Use PLDHashTable2 in nsSecureBrowserUIImpl. r=froydnj. (a6bf60fab)
- Bug 1168007 (part 7) - Use PLDHashTable2 in nsCertTree. r=froydnj. (7a0114da5)
- Bug 1168007 (part 8) - Use PLDHashTable2 in nsCycleCollector. r=froydnj. (61936a5b9)
- Bug 1168007 (part 9) - Use PLDHashTable2 in nsCacheEntry. r=froydnj. (64940f663)
- Bug 1168007 (part 10) - Use PLDHashTable2 in nsDiskCacheBindery. r=froydnj. (cb9993d4c)
- Bug 1168007 (part 11) - Use PLDHashTable2 exclusively in TestPLDHash. r=froydnj. (a871dfaa4)
- Bug 1170416 (part 1) - Remove PL_DHashTable{Init,Finish,Destroy){} and PL_NewDHashTable(). r=froydnj. (c7def8fcd)
- Bug 1170416 (part 2) - Merge PLDHashTable2 back into PLDHashTable. r=froydnj. (84783ae50)
- Bug 1168027 - Use PLDHashTable2 in nsTHashtable. r=froydnj. (ded8e0d51)
- Bug 1166598 (part 8) - Use PLDHashTable2 in nsHostResolver. r=froydnj. (b05946f51)
- Bug 1166598 (part 1) - Use PLDHashTable2 in nsScriptNameSpaceManager. r=froydnj. (cb9a9405f)
- Bug 1166598 (part 7) - Use PLDHashTable2 in nsLoadGroup. r=froydnj. (f886096a1)
- Bug 1166598 (part 2) - Use PLDHashTable2 in SpanningCellSorter. r=froydnj,dbaron. (67368e477)
- Bug 1166598 (part 3) - Use PLDHashTable2 in nsCommandParams. r=froydnj. (c4ea9cf33)
- Bug 1166598 (part 4) - Use PLDHashTable2 in RDFServiceImpl. r=froydnj. (26f9c3ab6)
- Bug 1166598 (part 5) - Use PLDHashTable2 in InMemoryDataSource. r=froydnj. (d2e130043)
- Bug 1166598 (part 6) - Clean up nsStaticCaseInsensitiveNameTable. r=froydnj. (eb8532cba)
- Bug 1166586 (part 1) - Remove all uses of PL_NewDHashTable() and PL_HashTableDestroy(). r=froydnj. (fc7222f1f)
- Bug 1129786 (part 1) - Instantiate RuleHash::m*Table eagerly. r=bz. (b95efc9aa)
- Bug 1129786 (part 2) - Instantiate nsDOMAttributeMap::mAttributeCache eagerly. r=bz. (f15221fa8)
- Bug 1166586 (part 2) - Convert some easy PL_DHashTable{Init,Finish} cases. r=froydnj. (a861a32c1)
- Bug 1165206 - Tweak nsTHashtable's move constructor. r=froydnj. (92724c440)
- Bug 1170069 - Use PLDHashTable2 in FontNameCache. r=froydnj. (150259ee5)
- Bug 1170416 (part 3) - Remove the PLDHashTable2 typedef. r=froydnj. (0c8123b29)
- Bug 1170416 (part 4) - Remove some unnecessary casts. r=froydnj. (5892abc55)
- Bug 1165786 - Remove PLDHashTable::SetOps(). r=froydnj. (75075e448)
- Bug 1170416 (part 5) - Remove PLDHashTable::IsInitialized(). r=froydnj. (9d6df3e68)
This commit is contained in:
@@ -154,7 +154,7 @@ nsSimpleContentList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto
|
||||
}
|
||||
|
||||
// Hashtable for storing nsContentLists
|
||||
static PLDHashTable2* gContentListHashTable;
|
||||
static PLDHashTable* gContentListHashTable;
|
||||
|
||||
#define RECENTLY_USED_CONTENT_LIST_CACHE_SIZE 31
|
||||
static nsContentList*
|
||||
@@ -218,7 +218,7 @@ NS_GetContentList(nsINode* aRootNode,
|
||||
// Initialize the hashtable if needed.
|
||||
if (!gContentListHashTable) {
|
||||
gContentListHashTable =
|
||||
new PLDHashTable2(&hash_table_ops, sizeof(ContentListHashEntry));
|
||||
new PLDHashTable(&hash_table_ops, sizeof(ContentListHashEntry));
|
||||
}
|
||||
|
||||
ContentListHashEntry *entry = nullptr;
|
||||
@@ -271,7 +271,7 @@ nsCacheableFuncStringHTMLCollection::WrapObject(JSContext *cx, JS::Handle<JSObje
|
||||
}
|
||||
|
||||
// Hashtable for storing nsCacheableFuncStringContentList
|
||||
static PLDHashTable2* gFuncStringContentListHashTable;
|
||||
static PLDHashTable* gFuncStringContentListHashTable;
|
||||
|
||||
struct FuncStringContentListHashEntry : public PLDHashEntryHdr
|
||||
{
|
||||
@@ -322,7 +322,7 @@ GetFuncStringContentList(nsINode* aRootNode,
|
||||
// Initialize the hashtable if needed.
|
||||
if (!gFuncStringContentListHashTable) {
|
||||
gFuncStringContentListHashTable =
|
||||
new PLDHashTable2(&hash_table_ops, sizeof(FuncStringContentListHashEntry));
|
||||
new PLDHashTable(&hash_table_ops, sizeof(FuncStringContentListHashEntry));
|
||||
}
|
||||
|
||||
FuncStringContentListHashEntry *entry = nullptr;
|
||||
|
||||
@@ -340,7 +340,7 @@ namespace {
|
||||
static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
|
||||
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
|
||||
|
||||
static PLDHashTable2* sEventListenerManagersHash;
|
||||
static PLDHashTable* sEventListenerManagersHash;
|
||||
|
||||
class DOMEventListenerManagersHashReporter final : public nsIMemoryReporter
|
||||
{
|
||||
@@ -502,7 +502,7 @@ nsContentUtils::Init()
|
||||
};
|
||||
|
||||
sEventListenerManagersHash =
|
||||
new PLDHashTable2(&hash_table_ops, sizeof(EventListenerManagerMapEntry));
|
||||
new PLDHashTable(&hash_table_ops, sizeof(EventListenerManagerMapEntry));
|
||||
|
||||
RegisterStrongMemoryReporter(new DOMEventListenerManagersHashReporter());
|
||||
}
|
||||
|
||||
@@ -51,17 +51,13 @@ RemoveMapRef(nsAttrHashKey::KeyType aKey, nsRefPtr<Attr>& aData,
|
||||
|
||||
nsDOMAttributeMap::~nsDOMAttributeMap()
|
||||
{
|
||||
if (mAttributeCache) {
|
||||
mAttributeCache->Enumerate(RemoveMapRef, nullptr);
|
||||
}
|
||||
mAttributeCache.Enumerate(RemoveMapRef, nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttributeMap::DropReference()
|
||||
{
|
||||
if (mAttributeCache) {
|
||||
mAttributeCache->Enumerate(RemoveMapRef, nullptr);
|
||||
}
|
||||
mAttributeCache.Enumerate(RemoveMapRef, nullptr);
|
||||
mContent = nullptr;
|
||||
}
|
||||
|
||||
@@ -87,9 +83,7 @@ TraverseMapEntry(nsAttrHashKey::KeyType aKey, nsRefPtr<Attr>& aData,
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMAttributeMap)
|
||||
if (tmp->mAttributeCache) {
|
||||
tmp->mAttributeCache->Enumerate(TraverseMapEntry, &cb);
|
||||
}
|
||||
tmp->mAttributeCache.Enumerate(TraverseMapEntry, &cb);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContent)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
@@ -143,10 +137,9 @@ SetOwnerDocumentFunc(nsAttrHashKey::KeyType aKey,
|
||||
nsresult
|
||||
nsDOMAttributeMap::SetOwnerDocument(nsIDocument* aDocument)
|
||||
{
|
||||
if (mAttributeCache) {
|
||||
uint32_t n = mAttributeCache->Enumerate(SetOwnerDocumentFunc, aDocument);
|
||||
NS_ENSURE_TRUE(n == mAttributeCache->Count(), NS_ERROR_FAILURE);
|
||||
}
|
||||
uint32_t n = mAttributeCache.Enumerate(SetOwnerDocumentFunc, aDocument);
|
||||
NS_ENSURE_TRUE(n == mAttributeCache.Count(), NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -154,15 +147,13 @@ void
|
||||
nsDOMAttributeMap::DropAttribute(int32_t aNamespaceID, nsIAtom* aLocalName)
|
||||
{
|
||||
nsAttrKey attr(aNamespaceID, aLocalName);
|
||||
if (mAttributeCache) {
|
||||
Attr *node = mAttributeCache->GetWeak(attr);
|
||||
if (node) {
|
||||
// Break link to map
|
||||
node->SetMap(nullptr);
|
||||
Attr *node = mAttributeCache.GetWeak(attr);
|
||||
if (node) {
|
||||
// Break link to map
|
||||
node->SetMap(nullptr);
|
||||
|
||||
// Remove from cache
|
||||
mAttributeCache->Remove(attr);
|
||||
}
|
||||
// Remove from cache
|
||||
mAttributeCache.Remove(attr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,13 +165,7 @@ nsDOMAttributeMap::RemoveAttribute(mozilla::dom::NodeInfo* aNodeInfo)
|
||||
nsAttrKey attr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom());
|
||||
|
||||
nsRefPtr<Attr> node;
|
||||
if (mAttributeCache && mAttributeCache->Get(attr, getter_AddRefs(node))) {
|
||||
// Break link to map
|
||||
node->SetMap(nullptr);
|
||||
|
||||
// Remove from cache
|
||||
mAttributeCache->Remove(attr);
|
||||
} else {
|
||||
if (!mAttributeCache.Get(attr, getter_AddRefs(node))) {
|
||||
nsAutoString value;
|
||||
// As we are removing the attribute we need to set the current value in
|
||||
// the attribute node.
|
||||
@@ -188,6 +173,13 @@ nsDOMAttributeMap::RemoveAttribute(mozilla::dom::NodeInfo* aNodeInfo)
|
||||
nsRefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
node = new Attr(nullptr, ni.forget(), value, true);
|
||||
}
|
||||
else {
|
||||
// Break link to map
|
||||
node->SetMap(nullptr);
|
||||
|
||||
// Remove from cache
|
||||
mAttributeCache.Remove(attr);
|
||||
}
|
||||
|
||||
return node.forget();
|
||||
}
|
||||
@@ -199,13 +191,12 @@ nsDOMAttributeMap::GetAttribute(mozilla::dom::NodeInfo* aNodeInfo, bool aNsAware
|
||||
|
||||
nsAttrKey attr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom());
|
||||
|
||||
EnsureAttributeCache();
|
||||
Attr* node = mAttributeCache->GetWeak(attr);
|
||||
Attr* node = mAttributeCache.GetWeak(attr);
|
||||
if (!node) {
|
||||
nsRefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
nsRefPtr<Attr> newAttr =
|
||||
new Attr(this, ni.forget(), EmptyString(), aNsAware);
|
||||
mAttributeCache->Put(attr, newAttr);
|
||||
mAttributeCache.Put(attr, newAttr);
|
||||
node = newAttr;
|
||||
}
|
||||
|
||||
@@ -251,14 +242,6 @@ nsDOMAttributeMap::GetNamedItem(const nsAString& aAttrName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttributeMap::EnsureAttributeCache()
|
||||
{
|
||||
if (!mAttributeCache) {
|
||||
mAttributeCache = MakeUnique<AttrCache>();
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttributeMap::SetNamedItem(nsIDOMAttr* aAttr, nsIDOMAttr** aReturn)
|
||||
{
|
||||
@@ -365,8 +348,7 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr,
|
||||
// Add the new attribute to the attribute map before updating
|
||||
// its value in the element. @see bug 364413.
|
||||
nsAttrKey attrkey(ni->NamespaceID(), ni->NameAtom());
|
||||
EnsureAttributeCache();
|
||||
mAttributeCache->Put(attrkey, &aAttr);
|
||||
mAttributeCache.Put(attrkey, &aAttr);
|
||||
aAttr.SetMap(this);
|
||||
|
||||
rv = mContent->SetAttr(ni->NamespaceID(), ni->NameAtom(),
|
||||
@@ -554,14 +536,14 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
|
||||
uint32_t
|
||||
nsDOMAttributeMap::Count() const
|
||||
{
|
||||
return mAttributeCache ? mAttributeCache->Count() : 0;
|
||||
return mAttributeCache.Count();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsDOMAttributeMap::Enumerate(AttrCache::EnumReadFunction aFunc,
|
||||
void *aUserArg) const
|
||||
{
|
||||
return mAttributeCache ? mAttributeCache->EnumerateRead(aFunc, aUserArg) : 0;
|
||||
return mAttributeCache.EnumerateRead(aFunc, aUserArg);
|
||||
}
|
||||
|
||||
size_t
|
||||
@@ -577,10 +559,8 @@ size_t
|
||||
nsDOMAttributeMap::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
size_t n = aMallocSizeOf(this);
|
||||
n += mAttributeCache
|
||||
? mAttributeCache->SizeOfExcludingThis(AttrCacheSizeEnumerator,
|
||||
aMallocSizeOf)
|
||||
: 0;
|
||||
n += mAttributeCache.SizeOfExcludingThis(AttrCacheSizeEnumerator,
|
||||
aMallocSizeOf);
|
||||
|
||||
// NB: mContent is non-owning and thus not counted.
|
||||
return n;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#define nsDOMAttributeMap_h
|
||||
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/dom/Attr.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
@@ -187,11 +186,9 @@ private:
|
||||
nsCOMPtr<Element> mContent;
|
||||
|
||||
/**
|
||||
* Cache of Attrs. It's usually empty, and thus initialized lazily.
|
||||
* Cache of Attrs.
|
||||
*/
|
||||
mozilla::UniquePtr<AttrCache> mAttributeCache;
|
||||
|
||||
void EnsureAttributeCache();
|
||||
AttrCache mAttributeCache;
|
||||
|
||||
/**
|
||||
* SetNamedItem() (aWithNS = false) and SetNamedItemNS() (aWithNS =
|
||||
|
||||
+8
-16
@@ -1702,11 +1702,8 @@ nsDocument::~nsDocument()
|
||||
|
||||
// Kill the subdocument map, doing this will release its strong
|
||||
// references, if any.
|
||||
if (mSubDocuments) {
|
||||
PL_DHashTableDestroy(mSubDocuments);
|
||||
|
||||
mSubDocuments = nullptr;
|
||||
}
|
||||
delete mSubDocuments;
|
||||
mSubDocuments = nullptr;
|
||||
|
||||
// Destroy link map now so we don't waste time removing
|
||||
// links one by one
|
||||
@@ -2016,7 +2013,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
|
||||
tmp->mAnimationController->Traverse(&cb);
|
||||
}
|
||||
|
||||
if (tmp->mSubDocuments && tmp->mSubDocuments->IsInitialized()) {
|
||||
if (tmp->mSubDocuments) {
|
||||
PL_DHashTableEnumerate(tmp->mSubDocuments, SubDocTraverser, &cb);
|
||||
}
|
||||
|
||||
@@ -2106,10 +2103,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||
tmp->mStyleSheetSetList = nullptr;
|
||||
}
|
||||
|
||||
if (tmp->mSubDocuments) {
|
||||
PL_DHashTableDestroy(tmp->mSubDocuments);
|
||||
tmp->mSubDocuments = nullptr;
|
||||
}
|
||||
delete tmp->mSubDocuments;
|
||||
tmp->mSubDocuments = nullptr;
|
||||
|
||||
tmp->mFrameRequestCallbacks.Clear();
|
||||
|
||||
@@ -2305,11 +2300,8 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
||||
|
||||
// Delete references to sub-documents and kill the subdocument map,
|
||||
// if any. It holds strong references
|
||||
if (mSubDocuments) {
|
||||
PL_DHashTableDestroy(mSubDocuments);
|
||||
|
||||
mSubDocuments = nullptr;
|
||||
}
|
||||
delete mSubDocuments;
|
||||
mSubDocuments = nullptr;
|
||||
|
||||
// Destroy link map now so we don't waste time removing
|
||||
// links one by one
|
||||
@@ -4050,7 +4042,7 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc)
|
||||
SubDocInitEntry
|
||||
};
|
||||
|
||||
mSubDocuments = PL_NewDHashTable(&hash_table_ops, sizeof(SubDocMapEntry));
|
||||
mSubDocuments = new PLDHashTable(&hash_table_ops, sizeof(SubDocMapEntry));
|
||||
}
|
||||
|
||||
// Add a mapping to the hash table
|
||||
|
||||
@@ -216,11 +216,6 @@ nsPropertyTable::SetPropertyInternal(nsPropertyOwner aObject,
|
||||
} else {
|
||||
propertyList = new PropertyList(aPropertyName, aPropDtorFunc,
|
||||
aPropDtorData, aTransfer);
|
||||
if (!propertyList || !propertyList->mObjectValueMap.IsInitialized()) {
|
||||
delete propertyList;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
propertyList->mNext = mPropertyList;
|
||||
mPropertyList = propertyList;
|
||||
}
|
||||
@@ -287,21 +282,18 @@ nsPropertyTable::PropertyList::PropertyList(nsIAtom *aName,
|
||||
void *aDtorData,
|
||||
bool aTransfer)
|
||||
: mName(aName),
|
||||
mObjectValueMap(PL_DHashGetStubOps(), sizeof(PropertyListMapEntry)),
|
||||
mDtorFunc(aDtorFunc),
|
||||
mDtorData(aDtorData),
|
||||
mTransfer(aTransfer),
|
||||
mNext(nullptr)
|
||||
{
|
||||
PL_DHashTableInit(&mObjectValueMap, PL_DHashGetStubOps(),
|
||||
sizeof(PropertyListMapEntry));
|
||||
}
|
||||
|
||||
nsPropertyTable::PropertyList::~PropertyList()
|
||||
{
|
||||
PL_DHashTableFinish(&mObjectValueMap);
|
||||
}
|
||||
|
||||
|
||||
static PLDHashOperator
|
||||
DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||
uint32_t number, void *arg)
|
||||
|
||||
@@ -119,20 +119,29 @@ NS_IMPL_ISUPPORTS(
|
||||
nsISupportsWeakReference,
|
||||
nsIMemoryReporter)
|
||||
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
GlobalNameHashHashKey,
|
||||
GlobalNameHashMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
GlobalNameHashClearEntry,
|
||||
GlobalNameHashInitEntry
|
||||
};
|
||||
|
||||
#define GLOBALNAME_HASHTABLE_INITIAL_LENGTH 512
|
||||
|
||||
nsScriptNameSpaceManager::nsScriptNameSpaceManager()
|
||||
: mIsInitialized(false)
|
||||
: mGlobalNames(&hash_table_ops, sizeof(GlobalNameMapEntry),
|
||||
GLOBALNAME_HASHTABLE_INITIAL_LENGTH)
|
||||
, mNavigatorNames(&hash_table_ops, sizeof(GlobalNameMapEntry),
|
||||
GLOBALNAME_HASHTABLE_INITIAL_LENGTH)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsScriptNameSpaceManager);
|
||||
}
|
||||
|
||||
nsScriptNameSpaceManager::~nsScriptNameSpaceManager()
|
||||
{
|
||||
if (mIsInitialized) {
|
||||
UnregisterWeakMemoryReporter(this);
|
||||
// Destroy the hash
|
||||
PL_DHashTableFinish(&mGlobalNames);
|
||||
PL_DHashTableFinish(&mNavigatorNames);
|
||||
}
|
||||
UnregisterWeakMemoryReporter(this);
|
||||
MOZ_COUNT_DTOR(nsScriptNameSpaceManager);
|
||||
}
|
||||
|
||||
@@ -309,30 +318,9 @@ nsScriptNameSpaceManager::RegisterInterface(const char* aIfName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define GLOBALNAME_HASHTABLE_INITIAL_LENGTH 512
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::Init()
|
||||
{
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
GlobalNameHashHashKey,
|
||||
GlobalNameHashMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
GlobalNameHashClearEntry,
|
||||
GlobalNameHashInitEntry
|
||||
};
|
||||
|
||||
PL_DHashTableInit(&mGlobalNames, &hash_table_ops,
|
||||
sizeof(GlobalNameMapEntry),
|
||||
GLOBALNAME_HASHTABLE_INITIAL_LENGTH);
|
||||
|
||||
PL_DHashTableInit(&mNavigatorNames, &hash_table_ops,
|
||||
sizeof(GlobalNameMapEntry),
|
||||
GLOBALNAME_HASHTABLE_INITIAL_LENGTH);
|
||||
|
||||
mIsInitialized = true;
|
||||
|
||||
RegisterWeakMemoryReporter(this);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@@ -236,8 +236,6 @@ private:
|
||||
|
||||
PLDHashTable mGlobalNames;
|
||||
PLDHashTable mNavigatorNames;
|
||||
|
||||
bool mIsInitialized;
|
||||
};
|
||||
|
||||
#endif /* nsScriptNameSpaceManager_h__ */
|
||||
|
||||
@@ -83,7 +83,7 @@ static JSObjWrapperTable sJSObjWrappers;
|
||||
static bool sJSObjWrappersAccessible = false;
|
||||
|
||||
// Hash of NPObject wrappers that wrap NPObjects as JSObjects.
|
||||
static PLDHashTable2* sNPObjWrappers;
|
||||
static PLDHashTable* sNPObjWrappers;
|
||||
|
||||
// Global wrapper count. This includes JSObject wrappers *and*
|
||||
// NPObject wrappers. When this count goes to zero, there are no more
|
||||
@@ -401,7 +401,7 @@ CreateNPObjWrapperTable()
|
||||
}
|
||||
|
||||
sNPObjWrappers =
|
||||
new PLDHashTable2(PL_DHashGetStubOps(), sizeof(NPObjWrapperHashEntry));
|
||||
new PLDHashTable(PL_DHashGetStubOps(), sizeof(NPObjWrapperHashEntry));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1966,7 +1966,7 @@ NPObjWrapperPluginDestroyedCallback(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
if (entry->mNpp == nppcx->npp) {
|
||||
// HACK: temporarily hide the hash we're enumerating so that invalidate()
|
||||
// and deallocate() don't touch it.
|
||||
PLDHashTable2* tmp = static_cast<PLDHashTable2*>(table);
|
||||
PLDHashTable* tmp = static_cast<PLDHashTable*>(table);
|
||||
sNPObjWrappers = nullptr;
|
||||
|
||||
NPObject* npobj = entry->mNPObj;
|
||||
|
||||
@@ -215,9 +215,7 @@ XULDocument::~XULDocument()
|
||||
mPersistenceIds.Clear();
|
||||
|
||||
// Destroy our broadcaster map.
|
||||
if (mBroadcasterMap) {
|
||||
PL_DHashTableDestroy(mBroadcasterMap);
|
||||
}
|
||||
delete mBroadcasterMap;
|
||||
|
||||
delete mTemplateBuilderTable;
|
||||
|
||||
@@ -764,7 +762,7 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
|
||||
};
|
||||
|
||||
if (! mBroadcasterMap) {
|
||||
mBroadcasterMap = PL_NewDHashTable(&gOps, sizeof(BroadcasterMapEntry));
|
||||
mBroadcasterMap = new PLDHashTable(&gOps, sizeof(BroadcasterMapEntry));
|
||||
}
|
||||
|
||||
BroadcasterMapEntry* entry =
|
||||
|
||||
@@ -6,19 +6,13 @@
|
||||
#include "nsContentSupportMap.h"
|
||||
#include "nsXULElement.h"
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsContentSupportMap::Remove(nsIContent* aElement)
|
||||
{
|
||||
if (!mMap.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsIContent* child = aElement;
|
||||
do {
|
||||
PL_DHashTableRemove(&mMap, child);
|
||||
child = child->GetNextNode(aElement);
|
||||
} while(child);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,12 +47,12 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult Remove(nsIContent* aElement);
|
||||
void Remove(nsIContent* aElement);
|
||||
|
||||
void Clear() { mMap.Clear(); }
|
||||
|
||||
protected:
|
||||
PLDHashTable2 mMap;
|
||||
PLDHashTable mMap;
|
||||
|
||||
struct Entry : public PLDHashEntryHdr {
|
||||
nsIContent* mContent;
|
||||
|
||||
@@ -16,7 +16,7 @@ protected:
|
||||
nsIContent* mTemplate;
|
||||
};
|
||||
|
||||
PLDHashTable2 mTable;
|
||||
PLDHashTable mTable;
|
||||
|
||||
public:
|
||||
nsTemplateMap() : mTable(PL_DHashGetStubOps(), sizeof(Entry)) { }
|
||||
|
||||
@@ -31,7 +31,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowserFind)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowserPersist)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsControllerCommandTable)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCommandManager)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCommandParams, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCommandParams)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsControllerCommandGroup)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBaseCommandController)
|
||||
|
||||
|
||||
@@ -25,20 +25,12 @@ const PLDHashTableOps nsCommandParams::sHashOps =
|
||||
NS_IMPL_ISUPPORTS(nsCommandParams, nsICommandParams)
|
||||
|
||||
nsCommandParams::nsCommandParams()
|
||||
: mValuesHash(&sHashOps, sizeof(HashEntry), 2)
|
||||
{
|
||||
// init the hash table later
|
||||
}
|
||||
|
||||
nsCommandParams::~nsCommandParams()
|
||||
{
|
||||
PL_DHashTableFinish(&mValuesHash);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCommandParams::Init()
|
||||
{
|
||||
PL_DHashTableInit(&mValuesHash, &sHashOps, sizeof(HashEntry), 2);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@@ -20,8 +20,6 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICOMMANDPARAMS
|
||||
|
||||
nsresult Init();
|
||||
|
||||
protected:
|
||||
virtual ~nsCommandParams();
|
||||
|
||||
|
||||
+2
-15
@@ -39,21 +39,8 @@ void nsColorNames::AddRefTable(void)
|
||||
{
|
||||
NS_ASSERTION(!gColorTable, "pre existing array!");
|
||||
if (!gColorTable) {
|
||||
gColorTable = new nsStaticCaseInsensitiveNameTable();
|
||||
if (gColorTable) {
|
||||
#ifdef DEBUG
|
||||
{
|
||||
// let's verify the table...
|
||||
for (uint32_t index = 0; index < eColorName_COUNT; ++index) {
|
||||
nsAutoCString temp1(kColorNames[index]);
|
||||
nsAutoCString temp2(kColorNames[index]);
|
||||
ToLowerCase(temp1);
|
||||
NS_ASSERTION(temp1.Equals(temp2), "upper case char in table");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
gColorTable->Init(kColorNames, eColorName_COUNT);
|
||||
}
|
||||
gColorTable =
|
||||
new nsStaticCaseInsensitiveNameTable(kColorNames, eColorName_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -617,8 +617,16 @@ FT2FontFamily::AddFacesToFontList(InfallibleTArray<FontListEntry>* aFontList,
|
||||
class FontNameCache {
|
||||
public:
|
||||
FontNameCache()
|
||||
: mWriteNeeded(false)
|
||||
: mMap(&mOps, sizeof(FNCMapEntry), 0)
|
||||
, mWriteNeeded(false)
|
||||
{
|
||||
// HACK ALERT: it's weird to assign |mOps| after we passed a pointer to
|
||||
// it to |mMap|'s constructor. A more normal approach here would be to
|
||||
// have a static |sOps| member. Unfortunately, this mysteriously but
|
||||
// consistently makes Fennec start-up slower, so we take this
|
||||
// unorthodox approach instead. It's safe because PLDHashTable's
|
||||
// constructor doesn't dereference the pointer; it just makes a copy of
|
||||
// it.
|
||||
mOps = (PLDHashTableOps) {
|
||||
StringHash,
|
||||
HashMatchEntry,
|
||||
@@ -627,8 +635,6 @@ public:
|
||||
nullptr
|
||||
};
|
||||
|
||||
PL_DHashTableInit(&mMap, &mOps, sizeof(FNCMapEntry), 0);
|
||||
|
||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default,
|
||||
"StartupCacheFontNameCache should only be used in chrome "
|
||||
"process");
|
||||
@@ -639,23 +645,18 @@ public:
|
||||
|
||||
~FontNameCache()
|
||||
{
|
||||
if (!mMap.IsInitialized()) {
|
||||
return;
|
||||
}
|
||||
if (!mWriteNeeded || !mCache) {
|
||||
PL_DHashTableFinish(&mMap);
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString buf;
|
||||
PL_DHashTableEnumerate(&mMap, WriteOutMap, &buf);
|
||||
PL_DHashTableFinish(&mMap);
|
||||
mCache->PutBuffer(CACHE_KEY, buf.get(), buf.Length() + 1);
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
if (!mMap.IsInitialized() || !mCache) {
|
||||
if (!mCache) {
|
||||
return;
|
||||
}
|
||||
uint32_t size;
|
||||
@@ -710,9 +711,6 @@ public:
|
||||
GetInfoForFile(const nsCString& aFileName, nsCString& aFaceList,
|
||||
uint32_t *aTimestamp, uint32_t *aFilesize)
|
||||
{
|
||||
if (!mMap.IsInitialized()) {
|
||||
return;
|
||||
}
|
||||
FNCMapEntry *entry =
|
||||
static_cast<FNCMapEntry*>(PL_DHashTableSearch(&mMap,
|
||||
aFileName.get()));
|
||||
@@ -731,9 +729,6 @@ public:
|
||||
CacheFileInfo(const nsCString& aFileName, const nsCString& aFaceList,
|
||||
uint32_t aTimestamp, uint32_t aFilesize)
|
||||
{
|
||||
if (!mMap.IsInitialized()) {
|
||||
return;
|
||||
}
|
||||
FNCMapEntry* entry = static_cast<FNCMapEntry*>
|
||||
(PL_DHashTableAdd(&mMap, aFileName.get(), fallible));
|
||||
if (entry) {
|
||||
|
||||
@@ -177,13 +177,12 @@ Native2WrappedNativeMap::newMap(int length)
|
||||
|
||||
Native2WrappedNativeMap::Native2WrappedNativeMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
mTable = new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
}
|
||||
|
||||
Native2WrappedNativeMap::~Native2WrappedNativeMap()
|
||||
{
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
size_t
|
||||
@@ -226,13 +225,12 @@ IID2WrappedJSClassMap::newMap(int length)
|
||||
|
||||
IID2WrappedJSClassMap::IID2WrappedJSClassMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = new PLDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
IID2WrappedJSClassMap::~IID2WrappedJSClassMap()
|
||||
{
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
|
||||
@@ -260,13 +258,12 @@ IID2NativeInterfaceMap::newMap(int length)
|
||||
|
||||
IID2NativeInterfaceMap::IID2NativeInterfaceMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = new PLDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
IID2NativeInterfaceMap::~IID2NativeInterfaceMap()
|
||||
{
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
size_t
|
||||
@@ -302,13 +299,12 @@ ClassInfo2NativeSetMap::newMap(int length)
|
||||
|
||||
ClassInfo2NativeSetMap::ClassInfo2NativeSetMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
mTable = new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
}
|
||||
|
||||
ClassInfo2NativeSetMap::~ClassInfo2NativeSetMap()
|
||||
{
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
size_t
|
||||
@@ -341,13 +337,12 @@ ClassInfo2WrappedNativeProtoMap::newMap(int length)
|
||||
|
||||
ClassInfo2WrappedNativeProtoMap::ClassInfo2WrappedNativeProtoMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
mTable = new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
}
|
||||
|
||||
ClassInfo2WrappedNativeProtoMap::~ClassInfo2WrappedNativeProtoMap()
|
||||
{
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
size_t
|
||||
@@ -462,13 +457,12 @@ NativeSetMap::newMap(int length)
|
||||
|
||||
NativeSetMap::NativeSetMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = new PLDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
NativeSetMap::~NativeSetMap()
|
||||
{
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
size_t
|
||||
@@ -526,13 +520,12 @@ IID2ThisTranslatorMap::newMap(int length)
|
||||
|
||||
IID2ThisTranslatorMap::IID2ThisTranslatorMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = new PLDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
IID2ThisTranslatorMap::~IID2ThisTranslatorMap()
|
||||
{
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
@@ -603,13 +596,12 @@ XPCNativeScriptableSharedMap::newMap(int length)
|
||||
|
||||
XPCNativeScriptableSharedMap::XPCNativeScriptableSharedMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = new PLDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
XPCNativeScriptableSharedMap::~XPCNativeScriptableSharedMap()
|
||||
{
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -655,14 +647,13 @@ XPCWrappedNativeProtoMap::newMap(int length)
|
||||
|
||||
XPCWrappedNativeProtoMap::XPCWrappedNativeProtoMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(),
|
||||
mTable = new PLDHashTable(PL_DHashGetStubOps(),
|
||||
sizeof(PLDHashEntryStub), length);
|
||||
}
|
||||
|
||||
XPCWrappedNativeProtoMap::~XPCWrappedNativeProtoMap()
|
||||
{
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@@ -164,13 +164,11 @@ nsFrameManager::GetPlaceholderFrameFor(const nsIFrame* aFrame)
|
||||
{
|
||||
NS_PRECONDITION(aFrame, "null param unexpected");
|
||||
|
||||
if (mPlaceholderMap.IsInitialized()) {
|
||||
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
|
||||
(PL_DHashTableSearch(const_cast<PLDHashTable2*>(&mPlaceholderMap),
|
||||
aFrame));
|
||||
if (entry) {
|
||||
return entry->placeholderFrame;
|
||||
}
|
||||
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
|
||||
(PL_DHashTableSearch(const_cast<PLDHashTable*>(&mPlaceholderMap),
|
||||
aFrame));
|
||||
if (entry) {
|
||||
return entry->placeholderFrame;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -201,10 +199,8 @@ nsFrameManager::UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame
|
||||
NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
|
||||
"unexpected frame type");
|
||||
|
||||
if (mPlaceholderMap.IsInitialized()) {
|
||||
PL_DHashTableRemove(&mPlaceholderMap,
|
||||
aPlaceholderFrame->GetOutOfFlowFrame());
|
||||
}
|
||||
PL_DHashTableRemove(&mPlaceholderMap,
|
||||
aPlaceholderFrame->GetOutOfFlowFrame());
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
@@ -219,10 +215,8 @@ UnregisterPlaceholders(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
void
|
||||
nsFrameManager::ClearPlaceholderFrameMap()
|
||||
{
|
||||
if (mPlaceholderMap.IsInitialized()) {
|
||||
PL_DHashTableEnumerate(&mPlaceholderMap, UnregisterPlaceholders, nullptr);
|
||||
mPlaceholderMap.Clear();
|
||||
}
|
||||
PL_DHashTableEnumerate(&mPlaceholderMap, UnregisterPlaceholders, nullptr);
|
||||
mPlaceholderMap.Clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -55,7 +55,7 @@ protected:
|
||||
// the pres shell owns the style set
|
||||
nsStyleSet* mStyleSet;
|
||||
nsIFrame* mRootFrame;
|
||||
PLDHashTable2 mPlaceholderMap;
|
||||
PLDHashTable mPlaceholderMap;
|
||||
UndisplayedMap* mUndisplayedMap;
|
||||
UndisplayedMap* mDisplayContentsMap;
|
||||
bool mIsDestroyingFrames; // The frame manager is destroying some frame(s).
|
||||
|
||||
@@ -27,24 +27,17 @@ nsCSSKeywords::AddRefTable(void)
|
||||
{
|
||||
if (0 == gKeywordTableRefCount++) {
|
||||
NS_ASSERTION(!gKeywordTable, "pre existing array!");
|
||||
gKeywordTable = new nsStaticCaseInsensitiveNameTable();
|
||||
if (gKeywordTable) {
|
||||
gKeywordTable =
|
||||
new nsStaticCaseInsensitiveNameTable(kCSSRawKeywords, eCSSKeyword_COUNT);
|
||||
#ifdef DEBUG
|
||||
{
|
||||
// let's verify the table...
|
||||
int32_t index = 0;
|
||||
for (; index < eCSSKeyword_COUNT && kCSSRawKeywords[index]; ++index) {
|
||||
nsAutoCString temp1(kCSSRawKeywords[index]);
|
||||
nsAutoCString temp2(kCSSRawKeywords[index]);
|
||||
ToLowerCase(temp1);
|
||||
NS_ASSERTION(temp1.Equals(temp2), "upper case char in table");
|
||||
NS_ASSERTION(-1 == temp1.FindChar('_'), "underscore char in table");
|
||||
}
|
||||
NS_ASSERTION(index == eCSSKeyword_COUNT, "kCSSRawKeywords and eCSSKeyword_COUNT are out of sync");
|
||||
}
|
||||
#endif
|
||||
gKeywordTable->Init(kCSSRawKeywords, eCSSKeyword_COUNT);
|
||||
// Partially verify the entries.
|
||||
int32_t index = 0;
|
||||
for (; index < eCSSKeyword_COUNT && kCSSRawKeywords[index]; ++index) {
|
||||
nsAutoCString temp(kCSSRawKeywords[index]);
|
||||
NS_ASSERTION(-1 == temp.FindChar('_'), "underscore char in table");
|
||||
}
|
||||
NS_ASSERTION(index == eCSSKeyword_COUNT, "kCSSRawKeywords and eCSSKeyword_COUNT are out of sync");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,22 +119,15 @@ static nsCSSProperty gAliases[eCSSAliasCount != 0 ? eCSSAliasCount : 1] = {
|
||||
nsStaticCaseInsensitiveNameTable*
|
||||
CreateStaticTable(const char* const aRawTable[], int32_t aLength)
|
||||
{
|
||||
auto table = new nsStaticCaseInsensitiveNameTable();
|
||||
if (table) {
|
||||
auto table = new nsStaticCaseInsensitiveNameTable(aRawTable, aLength);
|
||||
#ifdef DEBUG
|
||||
// let's verify the table...
|
||||
for (int32_t index = 0; index < aLength; ++index) {
|
||||
nsAutoCString temp1(aRawTable[index]);
|
||||
nsAutoCString temp2(aRawTable[index]);
|
||||
ToLowerCase(temp1);
|
||||
MOZ_ASSERT(temp1.Equals(temp2),
|
||||
"upper case char in case insensitive name table");
|
||||
MOZ_ASSERT(-1 == temp1.FindChar('_'),
|
||||
"underscore char in case insensitive name table");
|
||||
}
|
||||
#endif
|
||||
table->Init(aRawTable, aLength);
|
||||
// Partially verify the entries.
|
||||
for (int32_t index = 0; index < aLength; ++index) {
|
||||
nsAutoCString temp(aRawTable[index]);
|
||||
MOZ_ASSERT(-1 == temp.FindChar('_'),
|
||||
"underscore char in case insensitive name table");
|
||||
}
|
||||
#endif
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
@@ -449,7 +449,7 @@ protected:
|
||||
void AppendUniversalRule(const RuleSelectorPair& aRuleInfo);
|
||||
|
||||
int32_t mRuleCount;
|
||||
// The hashtables are lazily initialized.
|
||||
|
||||
PLDHashTable mIdTable;
|
||||
PLDHashTable mClassTable;
|
||||
PLDHashTable mTagTable;
|
||||
@@ -489,6 +489,14 @@ protected:
|
||||
|
||||
RuleHash::RuleHash(bool aQuirksMode)
|
||||
: mRuleCount(0),
|
||||
mIdTable(aQuirksMode ? &RuleHash_IdTable_CIOps.ops
|
||||
: &RuleHash_IdTable_CSOps.ops,
|
||||
sizeof(RuleHashTableEntry)),
|
||||
mClassTable(aQuirksMode ? &RuleHash_ClassTable_CIOps.ops
|
||||
: &RuleHash_ClassTable_CSOps.ops,
|
||||
sizeof(RuleHashTableEntry)),
|
||||
mTagTable(&RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)),
|
||||
mNameSpaceTable(&RuleHash_NameSpaceTable_Ops, sizeof(RuleHashTableEntry)),
|
||||
mUniversalRules(0),
|
||||
mEnumList(nullptr), mEnumListSize(0),
|
||||
mQuirksMode(aQuirksMode)
|
||||
@@ -549,19 +557,6 @@ RuleHash::~RuleHash()
|
||||
if (nullptr != mEnumList) {
|
||||
delete [] mEnumList;
|
||||
}
|
||||
// delete arena for strings and small objects
|
||||
if (mIdTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mIdTable);
|
||||
}
|
||||
if (mClassTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mClassTable);
|
||||
}
|
||||
if (mTagTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mTagTable);
|
||||
}
|
||||
if (mNameSpaceTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mNameSpaceTable);
|
||||
}
|
||||
}
|
||||
|
||||
void RuleHash::AppendRuleToTable(PLDHashTable* aTable, const void* aKey,
|
||||
@@ -600,31 +595,15 @@ void RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo)
|
||||
selector = selector->mNext;
|
||||
}
|
||||
if (nullptr != selector->mIDList) {
|
||||
if (!mIdTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&mIdTable,
|
||||
mQuirksMode ? &RuleHash_IdTable_CIOps.ops
|
||||
: &RuleHash_IdTable_CSOps.ops,
|
||||
sizeof(RuleHashTableEntry));
|
||||
}
|
||||
AppendRuleToTable(&mIdTable, selector->mIDList->mAtom, aRuleInfo);
|
||||
RULE_HASH_STAT_INCREMENT(mIdSelectors);
|
||||
}
|
||||
else if (nullptr != selector->mClassList) {
|
||||
if (!mClassTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&mClassTable,
|
||||
mQuirksMode ? &RuleHash_ClassTable_CIOps.ops
|
||||
: &RuleHash_ClassTable_CSOps.ops,
|
||||
sizeof(RuleHashTableEntry));
|
||||
}
|
||||
AppendRuleToTable(&mClassTable, selector->mClassList->mAtom, aRuleInfo);
|
||||
RULE_HASH_STAT_INCREMENT(mClassSelectors);
|
||||
}
|
||||
else if (selector->mLowercaseTag) {
|
||||
RuleValue ruleValue(aRuleInfo, mRuleCount++, mQuirksMode);
|
||||
if (!mTagTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&mTagTable, &RuleHash_TagTable_Ops,
|
||||
sizeof(RuleHashTagTableEntry));
|
||||
}
|
||||
AppendRuleToTagTable(&mTagTable, selector->mLowercaseTag, ruleValue);
|
||||
RULE_HASH_STAT_INCREMENT(mTagSelectors);
|
||||
if (selector->mCasedTag &&
|
||||
@@ -634,10 +613,6 @@ void RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo)
|
||||
}
|
||||
}
|
||||
else if (kNameSpaceID_Unknown != selector->mNameSpace) {
|
||||
if (!mNameSpaceTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&mNameSpaceTable, &RuleHash_NameSpaceTable_Ops,
|
||||
sizeof(RuleHashTableEntry));
|
||||
}
|
||||
AppendRuleToTable(&mNameSpaceTable,
|
||||
NS_INT32_TO_PTR(selector->mNameSpace), aRuleInfo);
|
||||
RULE_HASH_STAT_INCREMENT(mNameSpaceSelectors);
|
||||
@@ -694,7 +669,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
|
||||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(mUniversalRules, mElementUniversalCalls);
|
||||
}
|
||||
// universal rules within the namespace
|
||||
if (kNameSpaceID_Unknown != nameSpace && mNameSpaceTable.IsInitialized()) {
|
||||
if (kNameSpaceID_Unknown != nameSpace && mNameSpaceTable.EntryCount() > 0) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mNameSpaceTable, NS_INT32_TO_PTR(nameSpace)));
|
||||
if (entry) {
|
||||
@@ -702,7 +677,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
|
||||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementNameSpaceCalls);
|
||||
}
|
||||
}
|
||||
if (mTagTable.IsInitialized()) {
|
||||
if (mTagTable.EntryCount() > 0) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mTagTable, tag));
|
||||
if (entry) {
|
||||
@@ -710,7 +685,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
|
||||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementTagCalls);
|
||||
}
|
||||
}
|
||||
if (id && mIdTable.IsInitialized()) {
|
||||
if (id && mIdTable.EntryCount() > 0) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mIdTable, id));
|
||||
if (entry) {
|
||||
@@ -718,7 +693,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
|
||||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementIdCalls);
|
||||
}
|
||||
}
|
||||
if (mClassTable.IsInitialized()) {
|
||||
if (mClassTable.EntryCount() > 0) {
|
||||
for (int32_t index = 0; index < classCount; ++index) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mClassTable, classList->AtomAt(index)));
|
||||
@@ -781,29 +756,21 @@ RuleHash::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
size_t n = 0;
|
||||
|
||||
if (mIdTable.IsInitialized()) {
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mIdTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
}
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mIdTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
|
||||
if (mClassTable.IsInitialized()) {
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mClassTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
}
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mClassTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
|
||||
if (mTagTable.IsInitialized()) {
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mTagTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
}
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mTagTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
|
||||
if (mNameSpaceTable.IsInitialized()) {
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mNameSpaceTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
}
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mNameSpaceTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
|
||||
n += mUniversalRules.SizeOfExcludingThis(aMallocSizeOf);
|
||||
|
||||
@@ -888,42 +855,31 @@ struct RuleCascadeData {
|
||||
: mRuleHash(aQuirksMode),
|
||||
mStateSelectors(),
|
||||
mSelectorDocumentStates(0),
|
||||
mClassSelectors(aQuirksMode ? &AtomSelector_CIOps.ops
|
||||
: &AtomSelector_CSOps,
|
||||
sizeof(AtomSelectorEntry)),
|
||||
mIdSelectors(aQuirksMode ? &AtomSelector_CIOps.ops
|
||||
: &AtomSelector_CSOps,
|
||||
sizeof(AtomSelectorEntry)),
|
||||
// mAttributeSelectors is matching on the attribute _name_, not the
|
||||
// value, and we case-fold names at parse-time, so this is a
|
||||
// case-sensitive match.
|
||||
mAttributeSelectors(&AtomSelector_CSOps, sizeof(AtomSelectorEntry)),
|
||||
mAnonBoxRules(&RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)),
|
||||
#ifdef MOZ_XUL
|
||||
mXULTreeRules(&RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)),
|
||||
#endif
|
||||
mKeyframesRuleTable(),
|
||||
mCounterStyleRuleTable(),
|
||||
mCacheKey(aMedium),
|
||||
mNext(nullptr),
|
||||
mQuirksMode(aQuirksMode)
|
||||
{
|
||||
// mAttributeSelectors is matching on the attribute _name_, not the value,
|
||||
// and we case-fold names at parse-time, so this is a case-sensitive match.
|
||||
PL_DHashTableInit(&mAttributeSelectors, &AtomSelector_CSOps,
|
||||
sizeof(AtomSelectorEntry));
|
||||
PL_DHashTableInit(&mAnonBoxRules, &RuleHash_TagTable_Ops,
|
||||
sizeof(RuleHashTagTableEntry));
|
||||
PL_DHashTableInit(&mIdSelectors,
|
||||
aQuirksMode ? &AtomSelector_CIOps.ops :
|
||||
&AtomSelector_CSOps,
|
||||
sizeof(AtomSelectorEntry));
|
||||
PL_DHashTableInit(&mClassSelectors,
|
||||
aQuirksMode ? &AtomSelector_CIOps.ops :
|
||||
&AtomSelector_CSOps,
|
||||
sizeof(AtomSelectorEntry));
|
||||
memset(mPseudoElementRuleHashes, 0, sizeof(mPseudoElementRuleHashes));
|
||||
#ifdef MOZ_XUL
|
||||
PL_DHashTableInit(&mXULTreeRules, &RuleHash_TagTable_Ops,
|
||||
sizeof(RuleHashTagTableEntry));
|
||||
#endif
|
||||
}
|
||||
|
||||
~RuleCascadeData()
|
||||
{
|
||||
PL_DHashTableFinish(&mAttributeSelectors);
|
||||
PL_DHashTableFinish(&mAnonBoxRules);
|
||||
PL_DHashTableFinish(&mIdSelectors);
|
||||
PL_DHashTableFinish(&mClassSelectors);
|
||||
#ifdef MOZ_XUL
|
||||
PL_DHashTableFinish(&mXULTreeRules);
|
||||
#endif
|
||||
for (uint32_t i = 0; i < ArrayLength(mPseudoElementRuleHashes); ++i) {
|
||||
delete mPseudoElementRuleHashes[i];
|
||||
}
|
||||
@@ -3338,11 +3294,9 @@ struct CascadeEnumData {
|
||||
mPageRules(aPageRules),
|
||||
mCounterStyleRules(aCounterStyleRules),
|
||||
mCacheKey(aKey),
|
||||
mRulesByWeight(&gRulesByWeightOps, sizeof(RuleByWeightEntry), 32),
|
||||
mSheetType(aSheetType)
|
||||
{
|
||||
PL_DHashTableInit(&mRulesByWeight, &gRulesByWeightOps,
|
||||
sizeof(RuleByWeightEntry), 32);
|
||||
|
||||
// Initialize our arena
|
||||
PL_INIT_ARENA_POOL(&mArena, "CascadeEnumDataArena",
|
||||
NS_CASCADEENUMDATA_ARENA_BLOCK_SIZE);
|
||||
@@ -3350,8 +3304,6 @@ struct CascadeEnumData {
|
||||
|
||||
~CascadeEnumData()
|
||||
{
|
||||
if (mRulesByWeight.IsInitialized())
|
||||
PL_DHashTableFinish(&mRulesByWeight);
|
||||
PL_FinishArenaPool(&mArena);
|
||||
}
|
||||
|
||||
@@ -3565,9 +3517,6 @@ nsCSSRuleProcessor::RefreshRuleCascade(nsPresContext* aPresContext)
|
||||
newCascade->mCounterStyleRules,
|
||||
newCascade->mCacheKey,
|
||||
mSheetType);
|
||||
if (!data.mRulesByWeight.IsInitialized())
|
||||
return; /* out of memory */
|
||||
|
||||
for (uint32_t i = 0; i < mSheets.Length(); ++i) {
|
||||
if (!CascadeSheet(mSheets.ElementAt(i), &data))
|
||||
return; /* out of memory */
|
||||
|
||||
@@ -157,8 +157,8 @@ private:
|
||||
nsRefPtr<TableQuirkColorRule> mTableQuirkColorRule;
|
||||
nsRefPtr<TableTHRule> mTableTHRule;
|
||||
|
||||
PLDHashTable2 mMappedAttrTable;
|
||||
PLDHashTable2 mLangRuleTable;
|
||||
PLDHashTable mMappedAttrTable;
|
||||
PLDHashTable mLangRuleTable;
|
||||
};
|
||||
|
||||
#endif /* !defined(nsHTMLStyleSheet_h_) */
|
||||
|
||||
@@ -1431,7 +1431,7 @@ nsRuleNode::DestroyInternal(nsRuleNode ***aDestroyQueueTail)
|
||||
PL_DHashTableEnumerate(children, EnqueueRuleNodeChildren,
|
||||
&destroyQueueTail);
|
||||
*destroyQueueTail = nullptr; // ensure null-termination
|
||||
PL_DHashTableDestroy(children);
|
||||
delete children;
|
||||
} else if (HaveChildren()) {
|
||||
*destroyQueueTail = ChildrenList();
|
||||
do {
|
||||
@@ -1614,7 +1614,7 @@ nsRuleNode::ConvertChildrenToHash(int32_t aNumKids)
|
||||
{
|
||||
NS_ASSERTION(!ChildrenAreHashed() && HaveChildren(),
|
||||
"must have a non-empty list of children");
|
||||
PLDHashTable *hash = PL_NewDHashTable(&ChildrenHashOps,
|
||||
PLDHashTable *hash = new PLDHashTable(&ChildrenHashOps,
|
||||
sizeof(ChildrenHashEntry),
|
||||
aNumKids);
|
||||
for (nsRuleNode* curr = ChildrenList(); curr; curr = curr->mNextSibling) {
|
||||
@@ -9406,7 +9406,7 @@ nsRuleNode::SweepChildren(nsTArray<nsRuleNode*>& aSweepQueue)
|
||||
PL_DHashTableEnumerate(children, SweepHashEntry, &survivorsWithChildren);
|
||||
childrenDestroyed = oldChildCount - children->EntryCount();
|
||||
if (childrenDestroyed == oldChildCount) {
|
||||
PL_DHashTableDestroy(children);
|
||||
delete children;
|
||||
mChildren.asVoid = nullptr;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
SpanningCellSorter::SpanningCellSorter()
|
||||
: mState(ADDING)
|
||||
, mHashTable(&HashTableOps, sizeof(HashTableEntry))
|
||||
, mSortedHashTable(nullptr)
|
||||
{
|
||||
memset(mArray, 0, sizeof(mArray));
|
||||
@@ -23,9 +24,6 @@ SpanningCellSorter::SpanningCellSorter()
|
||||
|
||||
SpanningCellSorter::~SpanningCellSorter()
|
||||
{
|
||||
if (mHashTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mHashTable);
|
||||
}
|
||||
delete [] mSortedHashTable;
|
||||
}
|
||||
|
||||
@@ -70,10 +68,6 @@ SpanningCellSorter::AddCell(int32_t aColSpan, int32_t aRow, int32_t aCol)
|
||||
i->next = mArray[index];
|
||||
mArray[index] = i;
|
||||
} else {
|
||||
if (!mHashTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&mHashTable, &HashTableOps,
|
||||
sizeof(HashTableEntry));
|
||||
}
|
||||
HashTableEntry *entry = static_cast<HashTableEntry*>
|
||||
(PL_DHashTableAdd(&mHashTable, NS_INT32_TO_PTR(aColSpan),
|
||||
fallible));
|
||||
@@ -146,14 +140,9 @@ SpanningCellSorter::GetNext(int32_t *aColSpan)
|
||||
/* prepare to enumerate the hash */
|
||||
mState = ENUMERATING_HASH;
|
||||
mEnumerationIndex = 0;
|
||||
if (mHashTable.IsInitialized()) {
|
||||
if (mHashTable.EntryCount() > 0) {
|
||||
HashTableEntry **sh =
|
||||
new HashTableEntry*[mHashTable.EntryCount()];
|
||||
if (!sh) {
|
||||
// give up
|
||||
mState = DONE;
|
||||
return nullptr;
|
||||
}
|
||||
PL_DHashTableEnumerate(&mHashTable, FillSortedArray, sh);
|
||||
NS_QuickSort(sh, mHashTable.EntryCount(), sizeof(sh[0]),
|
||||
SortArray, nullptr);
|
||||
@@ -161,9 +150,7 @@ SpanningCellSorter::GetNext(int32_t *aColSpan)
|
||||
}
|
||||
/* fall through */
|
||||
case ENUMERATING_HASH:
|
||||
if (mHashTable.IsInitialized() &&
|
||||
mEnumerationIndex < mHashTable.EntryCount())
|
||||
{
|
||||
if (mEnumerationIndex < mHashTable.EntryCount()) {
|
||||
Item *result = mSortedHashTable[mEnumerationIndex]->mItems;
|
||||
*aColSpan = mSortedHashTable[mEnumerationIndex]->mColSpan;
|
||||
NS_ASSERTION(result, "holes in hash table");
|
||||
|
||||
@@ -541,9 +541,6 @@ NS_IMETHODIMP nsPrefBranch::GetChildList(const char *aStartingAt, uint32_t *aCou
|
||||
*aChildArray = nullptr;
|
||||
*aCount = 0;
|
||||
|
||||
if (!gHashTable->IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// this will contain a list of all the pref name strings
|
||||
// allocate on the stack for speed
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ matchPrefEntry(PLDHashTable*, const PLDHashEntryHdr* entry,
|
||||
return (strcmp(prefEntry->key, otherKey) == 0);
|
||||
}
|
||||
|
||||
PLDHashTable2* gHashTable;
|
||||
PLDHashTable* gHashTable;
|
||||
static PLArenaPool gPrefNameArena;
|
||||
bool gDirty = false;
|
||||
|
||||
@@ -150,9 +150,9 @@ static nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, u
|
||||
nsresult PREF_Init()
|
||||
{
|
||||
if (!gHashTable) {
|
||||
gHashTable = new PLDHashTable2(&pref_HashTableOps,
|
||||
sizeof(PrefHashEntry),
|
||||
PREF_HASHTABLE_INITIAL_LENGTH);
|
||||
gHashTable = new PLDHashTable(&pref_HashTableOps,
|
||||
sizeof(PrefHashEntry),
|
||||
PREF_HASHTABLE_INITIAL_LENGTH);
|
||||
|
||||
PL_INIT_ARENA_POOL(&gPrefNameArena, "PrefNameArena",
|
||||
PREFNAME_ARENA_SIZE);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
extern PLDHashTable2* gHashTable;
|
||||
extern PLDHashTable* gHashTable;
|
||||
extern bool gDirty;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@@ -42,6 +42,69 @@ static PRLogModuleInfo* gLoadGroupLog = nullptr;
|
||||
#undef LOG
|
||||
#define LOG(args) PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, args)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsLoadGroupConnectionInfo
|
||||
|
||||
class nsLoadGroupConnectionInfo final : public nsILoadGroupConnectionInfo
|
||||
{
|
||||
~nsLoadGroupConnectionInfo() {}
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSILOADGROUPCONNECTIONINFO
|
||||
|
||||
nsLoadGroupConnectionInfo();
|
||||
private:
|
||||
Atomic<uint32_t> mBlockingTransactionCount;
|
||||
nsAutoPtr<mozilla::net::SpdyPushCache> mSpdyCache;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsLoadGroupConnectionInfo, nsILoadGroupConnectionInfo)
|
||||
|
||||
nsLoadGroupConnectionInfo::nsLoadGroupConnectionInfo()
|
||||
: mBlockingTransactionCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroupConnectionInfo::GetBlockingTransactionCount(uint32_t *aBlockingTransactionCount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aBlockingTransactionCount);
|
||||
*aBlockingTransactionCount = mBlockingTransactionCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroupConnectionInfo::AddBlockingTransaction()
|
||||
{
|
||||
mBlockingTransactionCount++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroupConnectionInfo::RemoveBlockingTransaction(uint32_t *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
mBlockingTransactionCount--;
|
||||
*_retval = mBlockingTransactionCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] attribute SpdyPushCachePtr spdyPushCache; */
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroupConnectionInfo::GetSpdyPushCache(mozilla::net::SpdyPushCache **aSpdyPushCache)
|
||||
{
|
||||
*aSpdyPushCache = mSpdyCache.get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroupConnectionInfo::SetSpdyPushCache(mozilla::net::SpdyPushCache *aSpdyPushCache)
|
||||
{
|
||||
mSpdyCache = aSpdyPushCache;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RequestMapEntry : public PLDHashEntryHdr
|
||||
@@ -85,6 +148,14 @@ RequestHashInitEntry(PLDHashEntryHdr *entry, const void *key)
|
||||
new (entry) RequestMapEntry(request);
|
||||
}
|
||||
|
||||
static const PLDHashTableOps sRequestHashOps =
|
||||
{
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
RequestHashMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
RequestHashClearEntry,
|
||||
RequestHashInitEntry
|
||||
};
|
||||
|
||||
static void
|
||||
RescheduleRequest(nsIRequest *aRequest, int32_t delta)
|
||||
@@ -105,11 +176,12 @@ RescheduleRequests(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
|
||||
nsLoadGroup::nsLoadGroup(nsISupports* outer)
|
||||
: mForegroundCount(0)
|
||||
, mLoadFlags(LOAD_NORMAL)
|
||||
, mDefaultLoadFlags(0)
|
||||
, mConnectionInfo(new nsLoadGroupConnectionInfo())
|
||||
, mRequests(&sRequestHashOps, sizeof(RequestMapEntry))
|
||||
, mStatus(NS_OK)
|
||||
, mPriority(PRIORITY_NORMAL)
|
||||
, mIsCanceling(false)
|
||||
@@ -130,10 +202,6 @@ nsLoadGroup::~nsLoadGroup()
|
||||
DebugOnly<nsresult> rv = Cancel(NS_BINDING_ABORTED);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed");
|
||||
|
||||
if (mRequests.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mRequests);
|
||||
}
|
||||
|
||||
mDefaultLoadRequest = 0;
|
||||
|
||||
LOG(("LOADGROUP [%x]: Destroyed.\n", this));
|
||||
@@ -828,85 +896,4 @@ nsresult nsLoadGroup::MergeLoadFlags(nsIRequest *aRequest, nsLoadFlags& outFlags
|
||||
return rv;
|
||||
}
|
||||
|
||||
// nsLoadGroupConnectionInfo
|
||||
|
||||
class nsLoadGroupConnectionInfo final : public nsILoadGroupConnectionInfo
|
||||
{
|
||||
~nsLoadGroupConnectionInfo() {}
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSILOADGROUPCONNECTIONINFO
|
||||
|
||||
nsLoadGroupConnectionInfo();
|
||||
private:
|
||||
Atomic<uint32_t> mBlockingTransactionCount;
|
||||
nsAutoPtr<mozilla::net::SpdyPushCache> mSpdyCache;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsLoadGroupConnectionInfo, nsILoadGroupConnectionInfo)
|
||||
|
||||
nsLoadGroupConnectionInfo::nsLoadGroupConnectionInfo()
|
||||
: mBlockingTransactionCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroupConnectionInfo::GetBlockingTransactionCount(uint32_t *aBlockingTransactionCount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aBlockingTransactionCount);
|
||||
*aBlockingTransactionCount = mBlockingTransactionCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroupConnectionInfo::AddBlockingTransaction()
|
||||
{
|
||||
mBlockingTransactionCount++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroupConnectionInfo::RemoveBlockingTransaction(uint32_t *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
mBlockingTransactionCount--;
|
||||
*_retval = mBlockingTransactionCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] attribute SpdyPushCachePtr spdyPushCache; */
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroupConnectionInfo::GetSpdyPushCache(mozilla::net::SpdyPushCache **aSpdyPushCache)
|
||||
{
|
||||
*aSpdyPushCache = mSpdyCache.get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroupConnectionInfo::SetSpdyPushCache(mozilla::net::SpdyPushCache *aSpdyPushCache)
|
||||
{
|
||||
mSpdyCache = aSpdyPushCache;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsLoadGroup::Init()
|
||||
{
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
RequestHashMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
RequestHashClearEntry,
|
||||
RequestHashInitEntry
|
||||
};
|
||||
|
||||
PL_DHashTableInit(&mRequests, &hash_table_ops,
|
||||
sizeof(RequestMapEntry));
|
||||
|
||||
mConnectionInfo = new nsLoadGroupConnectionInfo();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#undef LOG
|
||||
|
||||
@@ -50,12 +50,9 @@ public:
|
||||
// nsLoadGroup methods:
|
||||
|
||||
explicit nsLoadGroup(nsISupports* outer);
|
||||
|
||||
nsresult Init();
|
||||
|
||||
protected:
|
||||
virtual ~nsLoadGroup();
|
||||
|
||||
protected:
|
||||
nsresult MergeLoadFlags(nsIRequest *aRequest, nsLoadFlags& flags);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -113,7 +113,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSafeFileOutputStream)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileStream)
|
||||
|
||||
NS_GENERIC_AGGREGATED_CONSTRUCTOR_INIT(nsLoadGroup, Init)
|
||||
NS_GENERIC_AGGREGATED_CONSTRUCTOR(nsLoadGroup)
|
||||
|
||||
#include "ArrayBufferInputStream.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(ArrayBufferInputStream)
|
||||
|
||||
Vendored
+5
-5
@@ -382,7 +382,8 @@ nsCacheEntryHashTable::ops =
|
||||
|
||||
|
||||
nsCacheEntryHashTable::nsCacheEntryHashTable()
|
||||
: initialized(false)
|
||||
: table(&ops, sizeof(nsCacheEntryHashTableEntry), kInitialTableLength)
|
||||
, initialized(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCacheEntryHashTable);
|
||||
}
|
||||
@@ -396,19 +397,18 @@ nsCacheEntryHashTable::~nsCacheEntryHashTable()
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsCacheEntryHashTable::Init()
|
||||
{
|
||||
PL_DHashTableInit(&table, &ops, sizeof(nsCacheEntryHashTableEntry), 256);
|
||||
table.ClearAndPrepareForLength(kInitialTableLength);
|
||||
initialized = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsCacheEntryHashTable::Shutdown()
|
||||
{
|
||||
if (initialized) {
|
||||
PL_DHashTableFinish(&table);
|
||||
table.ClearAndPrepareForLength(kInitialTableLength);
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+5
-3
@@ -267,13 +267,13 @@ public:
|
||||
nsCacheEntryHashTable();
|
||||
~nsCacheEntryHashTable();
|
||||
|
||||
nsresult Init();
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
nsCacheEntry *GetEntry( const nsCString * key);
|
||||
nsresult AddEntry( nsCacheEntry *entry);
|
||||
void RemoveEntry( nsCacheEntry *entry);
|
||||
|
||||
|
||||
void VisitEntries( PLDHashEnumerator etor, void *arg);
|
||||
|
||||
private:
|
||||
@@ -302,11 +302,13 @@ private:
|
||||
PLDHashEntryHdr * hdr,
|
||||
uint32_t number,
|
||||
void * arg);
|
||||
|
||||
|
||||
// member variables
|
||||
static const PLDHashTableOps ops;
|
||||
PLDHashTable table;
|
||||
bool initialized;
|
||||
|
||||
static const uint32_t kInitialTableLength = 256;
|
||||
};
|
||||
|
||||
#endif // _nsCacheEntry_h_
|
||||
|
||||
Vendored
+1
-2
@@ -1148,8 +1148,7 @@ nsCacheService::Init()
|
||||
}
|
||||
|
||||
// initialize hashtable for active cache entries
|
||||
rv = mActiveEntries.Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mActiveEntries.Init();
|
||||
|
||||
// create profile/preference observer
|
||||
if (!mObserver) {
|
||||
|
||||
Vendored
+5
-7
@@ -132,7 +132,8 @@ const PLDHashTableOps nsDiskCacheBindery::ops =
|
||||
|
||||
|
||||
nsDiskCacheBindery::nsDiskCacheBindery()
|
||||
: initialized(false)
|
||||
: table(&ops, sizeof(HashTableEntry), kInitialTableLength)
|
||||
, initialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -143,21 +144,18 @@ nsDiskCacheBindery::~nsDiskCacheBindery()
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsDiskCacheBindery::Init()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PL_DHashTableInit(&table, &ops, sizeof(HashTableEntry), 0);
|
||||
table.ClearAndPrepareForLength(kInitialTableLength);
|
||||
initialized = true;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
nsDiskCacheBindery::Reset()
|
||||
{
|
||||
if (initialized) {
|
||||
PL_DHashTableFinish(&table);
|
||||
table.ClearAndPrepareForLength(kInitialTableLength);
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+3
-1
@@ -97,7 +97,7 @@ public:
|
||||
nsDiskCacheBindery();
|
||||
~nsDiskCacheBindery();
|
||||
|
||||
nsresult Init();
|
||||
void Init();
|
||||
void Reset();
|
||||
|
||||
nsDiskCacheBinding * CreateBinding(nsCacheEntry * entry,
|
||||
@@ -116,6 +116,8 @@ private:
|
||||
static const PLDHashTableOps ops;
|
||||
PLDHashTable table;
|
||||
bool initialized;
|
||||
|
||||
static const uint32_t kInitialTableLength = 0;
|
||||
};
|
||||
|
||||
#endif /* _nsDiskCacheBinding_h_ */
|
||||
|
||||
Vendored
+2
-4
@@ -383,13 +383,11 @@ nsDiskCacheDevice::Init()
|
||||
NS_ERROR("Disk cache already initialized!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
||||
if (!mCacheDirectory)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = mBindery.Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
mBindery.Init();
|
||||
|
||||
// Open Disk Cache
|
||||
rv = OpenDiskCache();
|
||||
|
||||
+3
-3
@@ -54,9 +54,9 @@ nsMemoryCacheDevice::Init()
|
||||
{
|
||||
if (mInitialized) return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
nsresult rv = mMemCacheEntries.Init();
|
||||
mInitialized = NS_SUCCEEDED(rv);
|
||||
return rv;
|
||||
mMemCacheEntries.Init();
|
||||
mInitialized = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -547,6 +547,7 @@ nsHostResolver::nsHostResolver(uint32_t maxCacheEntries,
|
||||
, mNumIdleThreads(0)
|
||||
, mThreadCount(0)
|
||||
, mActiveAnyThreadCount(0)
|
||||
, mDB(&gHostDB_ops, sizeof(nsHostDBEnt), 0)
|
||||
, mEvictionQSize(0)
|
||||
, mPendingCount(0)
|
||||
, mShutdown(true)
|
||||
@@ -563,7 +564,6 @@ nsHostResolver::nsHostResolver(uint32_t maxCacheEntries,
|
||||
|
||||
nsHostResolver::~nsHostResolver()
|
||||
{
|
||||
PL_DHashTableFinish(&mDB);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -573,8 +573,6 @@ nsHostResolver::Init()
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PL_DHashTableInit(&mDB, &gHostDB_ops, sizeof(nsHostDBEnt), 0);
|
||||
|
||||
mShutdown = false;
|
||||
|
||||
#if TTL_AVAILABLE
|
||||
@@ -1434,8 +1432,6 @@ nsHostResolver::Create(uint32_t maxCacheEntries,
|
||||
|
||||
nsHostResolver *res = new nsHostResolver(maxCacheEntries, defaultCacheEntryLifetime,
|
||||
defaultGracePeriod);
|
||||
if (!res)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(res);
|
||||
|
||||
nsresult rv = res->Init();
|
||||
|
||||
@@ -40,7 +40,7 @@ struct HttpHeapAtom {
|
||||
char value[1];
|
||||
};
|
||||
|
||||
static PLDHashTable2 *sAtomTable;
|
||||
static PLDHashTable *sAtomTable;
|
||||
static struct HttpHeapAtom *sHeapAtoms = nullptr;
|
||||
static Mutex *sLock = nullptr;
|
||||
|
||||
@@ -103,8 +103,8 @@ nsHttp::CreateAtomTable()
|
||||
// The initial length for this table is a value greater than the number of
|
||||
// known atoms (NUM_HTTP_ATOMS) because we expect to encounter a few random
|
||||
// headers right off the bat.
|
||||
sAtomTable = new PLDHashTable2(&ops, sizeof(PLDHashEntryStub),
|
||||
NUM_HTTP_ATOMS + 10);
|
||||
sAtomTable = new PLDHashTable(&ops, sizeof(PLDHashEntryStub),
|
||||
NUM_HTTP_ATOMS + 10);
|
||||
|
||||
// fill the table with our known atoms
|
||||
const char *const atoms[] = {
|
||||
|
||||
@@ -65,8 +65,8 @@ static const PLDHashTableOps UnicodeToEntityOps = {
|
||||
nullptr,
|
||||
};
|
||||
|
||||
static PLDHashTable2* gEntityToUnicode;
|
||||
static PLDHashTable2* gUnicodeToEntity;
|
||||
static PLDHashTable* gEntityToUnicode;
|
||||
static PLDHashTable* gUnicodeToEntity;
|
||||
static nsrefcnt gTableRefCnt = 0;
|
||||
|
||||
#define HTML_ENTITY(_name, _value) { #_name, _value },
|
||||
@@ -81,12 +81,12 @@ nsresult
|
||||
nsHTMLEntities::AddRefTable(void)
|
||||
{
|
||||
if (!gTableRefCnt) {
|
||||
gEntityToUnicode = new PLDHashTable2(&EntityToUnicodeOps,
|
||||
sizeof(EntityNodeEntry),
|
||||
NS_HTML_ENTITY_COUNT);
|
||||
gUnicodeToEntity = new PLDHashTable2(&UnicodeToEntityOps,
|
||||
sizeof(EntityNodeEntry),
|
||||
NS_HTML_ENTITY_COUNT);
|
||||
gEntityToUnicode = new PLDHashTable(&EntityToUnicodeOps,
|
||||
sizeof(EntityNodeEntry),
|
||||
NS_HTML_ENTITY_COUNT);
|
||||
gUnicodeToEntity = new PLDHashTable(&UnicodeToEntityOps,
|
||||
sizeof(EntityNodeEntry),
|
||||
NS_HTML_ENTITY_COUNT);
|
||||
for (const EntityNode *node = gEntityArray,
|
||||
*node_end = ArrayEnd(gEntityArray);
|
||||
node < node_end; ++node) {
|
||||
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
{
|
||||
struct hash
|
||||
{
|
||||
PLDHashTable* mPropertyHash;
|
||||
PLDHashTable* mPropertyHash;
|
||||
} hash;
|
||||
struct as
|
||||
{
|
||||
@@ -163,7 +163,7 @@ Assertion::Assertion(nsIRDFResource* aSource)
|
||||
NS_ADDREF(mSource);
|
||||
|
||||
u.hash.mPropertyHash =
|
||||
PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry));
|
||||
new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry));
|
||||
}
|
||||
|
||||
Assertion::Assertion(nsIRDFResource* aSource,
|
||||
@@ -194,7 +194,7 @@ Assertion::~Assertion()
|
||||
if (mHashEntry && u.hash.mPropertyHash) {
|
||||
PL_DHashTableEnumerate(u.hash.mPropertyHash, DeletePropertyHashEntry,
|
||||
nullptr);
|
||||
PL_DHashTableDestroy(u.hash.mPropertyHash);
|
||||
delete u.hash.mPropertyHash;
|
||||
u.hash.mPropertyHash = nullptr;
|
||||
}
|
||||
|
||||
@@ -250,8 +250,8 @@ protected:
|
||||
// nsIRDFResource object per unique URI). The value of an entry is
|
||||
// an Assertion struct, which is a linked list of (subject
|
||||
// predicate object) triples.
|
||||
PLDHashTable mForwardArcs;
|
||||
PLDHashTable mReverseArcs;
|
||||
PLDHashTable mForwardArcs;
|
||||
PLDHashTable mReverseArcs;
|
||||
|
||||
nsCOMArray<nsIRDFObserver> mObservers;
|
||||
uint32_t mNumObservers;
|
||||
@@ -286,7 +286,6 @@ protected:
|
||||
|
||||
explicit InMemoryDataSource(nsISupports* aOuter);
|
||||
virtual ~InMemoryDataSource();
|
||||
nsresult Init();
|
||||
|
||||
friend nsresult
|
||||
NS_NewRDFInMemoryDataSource(nsISupports* aOuter, const nsIID& aIID, void** aResult);
|
||||
@@ -752,16 +751,11 @@ NS_NewRDFInMemoryDataSource(nsISupports* aOuter, const nsIID& aIID, void** aResu
|
||||
}
|
||||
|
||||
InMemoryDataSource* datasource = new InMemoryDataSource(aOuter);
|
||||
if (! datasource)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(datasource);
|
||||
|
||||
nsresult rv = datasource->Init();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
datasource->fAggregated.AddRef();
|
||||
rv = datasource->AggregatedQueryInterface(aIID, aResult); // This'll AddRef()
|
||||
datasource->fAggregated.Release();
|
||||
}
|
||||
datasource->fAggregated.AddRef();
|
||||
nsresult rv = datasource->AggregatedQueryInterface(aIID, aResult); // This'll AddRef()
|
||||
datasource->fAggregated.Release();
|
||||
|
||||
NS_RELEASE(datasource);
|
||||
return rv;
|
||||
@@ -769,25 +763,18 @@ NS_NewRDFInMemoryDataSource(nsISupports* aOuter, const nsIID& aIID, void** aResu
|
||||
|
||||
|
||||
InMemoryDataSource::InMemoryDataSource(nsISupports* aOuter)
|
||||
: mNumObservers(0), mReadCount(0)
|
||||
: mForwardArcs(PL_DHashGetStubOps(), sizeof(Entry))
|
||||
, mReverseArcs(PL_DHashGetStubOps(), sizeof(Entry))
|
||||
, mNumObservers(0)
|
||||
, mReadCount(0)
|
||||
{
|
||||
NS_INIT_AGGREGATED(aOuter);
|
||||
|
||||
mPropagateChanges = true;
|
||||
MOZ_COUNT_CTOR(InMemoryDataSource);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
InMemoryDataSource::Init()
|
||||
{
|
||||
PL_DHashTableInit(&mForwardArcs, PL_DHashGetStubOps(), sizeof(Entry));
|
||||
PL_DHashTableInit(&mReverseArcs, PL_DHashGetStubOps(), sizeof(Entry));
|
||||
|
||||
if (! gLog)
|
||||
gLog = PR_NewLogModule("InMemoryDataSource");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -798,16 +785,13 @@ InMemoryDataSource::~InMemoryDataSource()
|
||||
fprintf(stdout, "%d - RDF: InMemoryDataSource\n", gInstanceCount);
|
||||
#endif
|
||||
|
||||
if (mForwardArcs.IsInitialized()) {
|
||||
if (mForwardArcs.EntryCount() > 0) {
|
||||
// This'll release all of the Assertion objects that are
|
||||
// associated with this data source. We only need to do this
|
||||
// for the forward arcs, because the reverse arcs table
|
||||
// indexes the exact same set of resources.
|
||||
PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, nullptr);
|
||||
PL_DHashTableFinish(&mForwardArcs);
|
||||
}
|
||||
if (mReverseArcs.IsInitialized())
|
||||
PL_DHashTableFinish(&mReverseArcs);
|
||||
|
||||
PR_LOG(gLog, PR_LOG_NOTICE,
|
||||
("InMemoryDataSource(%p): destroyed.", this));
|
||||
|
||||
@@ -719,7 +719,12 @@ RDFServiceImpl*
|
||||
RDFServiceImpl::gRDFService;
|
||||
|
||||
RDFServiceImpl::RDFServiceImpl()
|
||||
: mNamedDataSources(nullptr)
|
||||
: mNamedDataSources(nullptr)
|
||||
, mResources(&gResourceTableOps, sizeof(ResourceHashEntry))
|
||||
, mLiterals(&gLiteralTableOps, sizeof(LiteralHashEntry))
|
||||
, mInts(&gIntTableOps, sizeof(IntHashEntry))
|
||||
, mDates(&gDateTableOps, sizeof(DateHashEntry))
|
||||
, mBlobs(&gBlobTableOps, sizeof(BlobHashEntry))
|
||||
{
|
||||
gRDFService = this;
|
||||
}
|
||||
@@ -738,17 +743,6 @@ RDFServiceImpl::Init()
|
||||
if (! mNamedDataSources)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PL_DHashTableInit(&mResources, &gResourceTableOps,
|
||||
sizeof(ResourceHashEntry));
|
||||
|
||||
PL_DHashTableInit(&mLiterals, &gLiteralTableOps, sizeof(LiteralHashEntry));
|
||||
|
||||
PL_DHashTableInit(&mInts, &gIntTableOps, sizeof(IntHashEntry));
|
||||
|
||||
PL_DHashTableInit(&mDates, &gDateTableOps, sizeof(DateHashEntry));
|
||||
|
||||
PL_DHashTableInit(&mBlobs, &gBlobTableOps, sizeof(BlobHashEntry));
|
||||
|
||||
mDefaultResourceFactory = do_GetClassObject(kRDFDefaultResourceCID, &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get default resource factory");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@@ -766,16 +760,6 @@ RDFServiceImpl::~RDFServiceImpl()
|
||||
PL_HashTableDestroy(mNamedDataSources);
|
||||
mNamedDataSources = nullptr;
|
||||
}
|
||||
if (mResources.IsInitialized())
|
||||
PL_DHashTableFinish(&mResources);
|
||||
if (mLiterals.IsInitialized())
|
||||
PL_DHashTableFinish(&mLiterals);
|
||||
if (mInts.IsInitialized())
|
||||
PL_DHashTableFinish(&mInts);
|
||||
if (mDates.IsInitialized())
|
||||
PL_DHashTableFinish(&mDates);
|
||||
if (mBlobs.IsInitialized())
|
||||
PL_DHashTableFinish(&mBlobs);
|
||||
gRDFService = nullptr;
|
||||
}
|
||||
|
||||
@@ -793,9 +777,6 @@ RDFServiceImpl::CreateSingleton(nsISupports* aOuter,
|
||||
}
|
||||
|
||||
nsRefPtr<RDFServiceImpl> serv = new RDFServiceImpl();
|
||||
if (!serv)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = serv->Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@@ -149,7 +149,10 @@ nsCertTreeDispInfo::GetHostPort(nsAString &aHostPort)
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsCertTree, nsICertTree, nsITreeView)
|
||||
|
||||
nsCertTree::nsCertTree() : mTreeArray(nullptr)
|
||||
nsCertTree::nsCertTree()
|
||||
: mTreeArray(nullptr)
|
||||
, mCompareCache(&gMapOps, sizeof(CompareCacheHashEntryPtr),
|
||||
kInitialCacheLength)
|
||||
{
|
||||
static NS_DEFINE_CID(kNSSComponentCID, NS_NSSCOMPONENT_CID);
|
||||
|
||||
@@ -165,22 +168,11 @@ nsCertTree::nsCertTree() : mTreeArray(nullptr)
|
||||
|
||||
void nsCertTree::ClearCompareHash()
|
||||
{
|
||||
if (mCompareCache.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mCompareCache);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsCertTree::InitCompareHash()
|
||||
{
|
||||
ClearCompareHash();
|
||||
PL_DHashTableInit(&mCompareCache, &gMapOps,
|
||||
sizeof(CompareCacheHashEntryPtr), 64);
|
||||
return NS_OK;
|
||||
mCompareCache.ClearAndPrepareForLength(kInitialCacheLength);
|
||||
}
|
||||
|
||||
nsCertTree::~nsCertTree()
|
||||
{
|
||||
ClearCompareHash();
|
||||
delete [] mTreeArray;
|
||||
}
|
||||
|
||||
@@ -632,11 +624,11 @@ nsCertTree::LoadCertsFromCache(nsIX509CertList *aCache, uint32_t aType)
|
||||
mTreeArray = nullptr;
|
||||
mNumRows = 0;
|
||||
}
|
||||
nsresult rv = InitCompareHash();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
ClearCompareHash();
|
||||
|
||||
rv = GetCertsByTypeFromCache(aCache, aType,
|
||||
GetCompareFuncFromCertType(aType), &mCompareCache);
|
||||
nsresult rv = GetCertsByTypeFromCache(aCache, aType,
|
||||
GetCompareFuncFromCertType(aType),
|
||||
&mCompareCache);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return UpdateUIContents();
|
||||
}
|
||||
@@ -650,11 +642,10 @@ nsCertTree::LoadCerts(uint32_t aType)
|
||||
mTreeArray = nullptr;
|
||||
mNumRows = 0;
|
||||
}
|
||||
nsresult rv = InitCompareHash();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
ClearCompareHash();
|
||||
|
||||
rv = GetCertsByType(aType,
|
||||
GetCompareFuncFromCertType(aType), &mCompareCache);
|
||||
nsresult rv = GetCertsByType(aType, GetCompareFuncFromCertType(aType),
|
||||
&mCompareCache);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return UpdateUIContents();
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@ public:
|
||||
protected:
|
||||
virtual ~nsCertTree();
|
||||
|
||||
nsresult InitCompareHash();
|
||||
void ClearCompareHash();
|
||||
void RemoveCacheEntry(void *key);
|
||||
|
||||
@@ -117,6 +116,8 @@ protected:
|
||||
nsresult GetCertsByTypeFromCache(nsIX509CertList *aCache, uint32_t aType,
|
||||
nsCertCompareFunc aCertCmpFn, void *aCertCmpFnArg);
|
||||
private:
|
||||
static const uint32_t kInitialCacheLength = 64;
|
||||
|
||||
nsTArray< mozilla::RefPtr<nsCertTreeDispInfo> > mDispInfo;
|
||||
nsCOMPtr<nsITreeBoxObject> mTree;
|
||||
nsCOMPtr<nsITreeSelection> mSelection;
|
||||
|
||||
@@ -39,22 +39,15 @@ static const PLDHashTableOps gSetOps = {
|
||||
nsNSSShutDownList *nsNSSShutDownList::singleton = nullptr;
|
||||
|
||||
nsNSSShutDownList::nsNSSShutDownList()
|
||||
:mListLock("nsNSSShutDownList.mListLock")
|
||||
: mListLock("nsNSSShutDownList.mListLock")
|
||||
, mActiveSSLSockets(0)
|
||||
, mObjects(&gSetOps, sizeof(ObjectHashEntry))
|
||||
, mPK11LogoutCancelObjects(&gSetOps, sizeof(ObjectHashEntry))
|
||||
{
|
||||
mActiveSSLSockets = 0;
|
||||
PL_DHashTableInit(&mObjects, &gSetOps, sizeof(ObjectHashEntry));
|
||||
PL_DHashTableInit(&mPK11LogoutCancelObjects, &gSetOps,
|
||||
sizeof(ObjectHashEntry));
|
||||
}
|
||||
|
||||
nsNSSShutDownList::~nsNSSShutDownList()
|
||||
{
|
||||
if (mObjects.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mObjects);
|
||||
}
|
||||
if (mPK11LogoutCancelObjects.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mPK11LogoutCancelObjects);
|
||||
}
|
||||
PR_ASSERT(this == singleton);
|
||||
singleton = nullptr;
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ private:
|
||||
protected:
|
||||
mozilla::Mutex mListLock;
|
||||
static nsNSSShutDownList *singleton;
|
||||
PLDHashTable mObjects;
|
||||
uint32_t mActiveSSLSockets;
|
||||
PLDHashTable mObjects;
|
||||
PLDHashTable mPK11LogoutCancelObjects;
|
||||
nsNSSActivityState mActivityState;
|
||||
};
|
||||
|
||||
@@ -111,20 +111,14 @@ nsSecureBrowserUIImpl::nsSecureBrowserUIImpl()
|
||||
#ifdef DEBUG
|
||||
, mOnStateLocationChangeReentranceDetection(0)
|
||||
#endif
|
||||
, mTransferringRequests(&gMapOps, sizeof(RequestHashEntry))
|
||||
{
|
||||
ResetStateTracking();
|
||||
|
||||
|
||||
if (!gSecureDocLog)
|
||||
gSecureDocLog = PR_NewLogModule("nsSecureBrowserUI");
|
||||
}
|
||||
|
||||
nsSecureBrowserUIImpl::~nsSecureBrowserUIImpl()
|
||||
{
|
||||
if (mTransferringRequests.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mTransferringRequests);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsSecureBrowserUIImpl,
|
||||
nsISecureBrowserUI,
|
||||
nsIWebProgressListener,
|
||||
@@ -379,10 +373,7 @@ void nsSecureBrowserUIImpl::ResetStateTracking()
|
||||
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
|
||||
|
||||
mDocumentRequestsInProgress = 0;
|
||||
if (mTransferringRequests.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mTransferringRequests);
|
||||
}
|
||||
PL_DHashTableInit(&mTransferringRequests, &gMapOps, sizeof(RequestHashEntry));
|
||||
mTransferringRequests.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
NS_DECL_NSISSLSTATUSPROVIDER
|
||||
|
||||
protected:
|
||||
virtual ~nsSecureBrowserUIImpl();
|
||||
virtual ~nsSecureBrowserUIImpl() {};
|
||||
|
||||
mozilla::ReentrantMonitor mReentrantMonitor;
|
||||
|
||||
|
||||
@@ -91,12 +91,22 @@ class nsDefaultComparator <nsDocLoader::nsListenerInfo, nsIWebProgressListener*>
|
||||
}
|
||||
};
|
||||
|
||||
/* static */ const PLDHashTableOps nsDocLoader::sRequestInfoHashOps =
|
||||
{
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
nsDocLoader::RequestInfoHashClearEntry,
|
||||
nsDocLoader::RequestInfoHashInitEntry
|
||||
};
|
||||
|
||||
nsDocLoader::nsDocLoader()
|
||||
: mParent(nullptr),
|
||||
mCurrentSelfProgress(0),
|
||||
mMaxSelfProgress(0),
|
||||
mCurrentTotalProgress(0),
|
||||
mMaxTotalProgress(0),
|
||||
mRequestInfoHash(&sRequestInfoHashOps, sizeof(nsRequestInfo)),
|
||||
mCompletedTotalProgress(0),
|
||||
mIsLoadingDocument(false),
|
||||
mIsRestoringDocument(false),
|
||||
@@ -107,17 +117,6 @@ nsDocLoader::nsDocLoader()
|
||||
gDocLoaderLog = PR_NewLogModule("DocLoader");
|
||||
}
|
||||
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
RequestInfoHashClearEntry,
|
||||
RequestInfoHashInitEntry
|
||||
};
|
||||
|
||||
PL_DHashTableInit(&mRequestInfoHash, &hash_table_ops, sizeof(nsRequestInfo));
|
||||
|
||||
ClearInternalProgress();
|
||||
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
@@ -134,10 +133,6 @@ nsDocLoader::SetDocLoaderParent(nsDocLoader *aParent)
|
||||
nsresult
|
||||
nsDocLoader::Init()
|
||||
{
|
||||
if (!mRequestInfoHash.IsInitialized()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NewLoadGroup(getter_AddRefs(mLoadGroup), this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@@ -166,10 +161,6 @@ nsDocLoader::~nsDocLoader()
|
||||
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: deleted.\n", this));
|
||||
|
||||
if (mRequestInfoHash.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mRequestInfoHash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1358,12 +1349,6 @@ RemoveInfoCallback(PLDHashTable *table, PLDHashEntryHdr *hdr, uint32_t number,
|
||||
|
||||
void nsDocLoader::ClearRequestInfoHash(void)
|
||||
{
|
||||
if (!mRequestInfoHash.IsInitialized() || !mRequestInfoHash.EntryCount()) {
|
||||
// No hash, or the hash is empty, nothing to do here then...
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PL_DHashTableEnumerate(&mRequestInfoHash, RemoveInfoCallback, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -302,6 +302,8 @@ protected:
|
||||
bool mIsFlushingLayout;
|
||||
|
||||
private:
|
||||
static const PLDHashTableOps sRequestInfoHashOps;
|
||||
|
||||
// A list of kids that are in the middle of their onload calls and will let
|
||||
// us know once they're done. We don't want to fire onload for "normal"
|
||||
// DocLoaderIsEmpty calls (those coming from requests finishing in our
|
||||
|
||||
@@ -823,21 +823,20 @@ private:
|
||||
PLDHashTable mPtrToNodeMap;
|
||||
bool mOutOfMemory;
|
||||
|
||||
public:
|
||||
CCGraph() : mRootCount(0), mOutOfMemory(false) {}
|
||||
static const uint32_t kInitialMapLength = 16384;
|
||||
|
||||
~CCGraph()
|
||||
{
|
||||
if (mPtrToNodeMap.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mPtrToNodeMap);
|
||||
}
|
||||
}
|
||||
public:
|
||||
CCGraph()
|
||||
: mRootCount(0)
|
||||
, mPtrToNodeMap(&PtrNodeOps, sizeof(PtrToNodeEntry), kInitialMapLength)
|
||||
, mOutOfMemory(false)
|
||||
{}
|
||||
|
||||
~CCGraph() {}
|
||||
|
||||
void Init()
|
||||
{
|
||||
MOZ_ASSERT(IsEmpty(), "Failed to call CCGraph::Clear");
|
||||
PL_DHashTableInit(&mPtrToNodeMap, &PtrNodeOps,
|
||||
sizeof(PtrToNodeEntry), 16384);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
@@ -846,7 +845,7 @@ public:
|
||||
mEdges.Clear();
|
||||
mWeakMaps.Clear();
|
||||
mRootCount = 0;
|
||||
PL_DHashTableFinish(&mPtrToNodeMap);
|
||||
mPtrToNodeMap.ClearAndPrepareForLength(kInitialMapLength);
|
||||
mOutOfMemory = false;
|
||||
}
|
||||
|
||||
@@ -855,7 +854,7 @@ public:
|
||||
{
|
||||
return mNodes.IsEmpty() && mEdges.IsEmpty() &&
|
||||
mWeakMaps.IsEmpty() && mRootCount == 0 &&
|
||||
!mPtrToNodeMap.IsInitialized();
|
||||
mPtrToNodeMap.EntryCount() == 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ using namespace mozilla;
|
||||
* sure it's only manipulated from the main thread. Probably the latter
|
||||
* is better, since the former would hurt performance.
|
||||
*/
|
||||
static PLDHashTable2* gAtomTable;
|
||||
static PLDHashTable* gAtomTable;
|
||||
|
||||
class StaticAtomEntry : public PLDHashEntryHdr
|
||||
{
|
||||
@@ -542,8 +542,8 @@ static inline void
|
||||
EnsureTableExists()
|
||||
{
|
||||
if (!gAtomTable) {
|
||||
gAtomTable = new PLDHashTable2(&AtomTableOps, sizeof(AtomTableEntry),
|
||||
ATOM_HASHTABLE_INITIAL_LENGTH);
|
||||
gAtomTable = new PLDHashTable(&AtomTableOps, sizeof(AtomTableEntry),
|
||||
ATOM_HASHTABLE_INITIAL_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -459,19 +459,14 @@ nsPropertiesParser::ParseBuffer(const char16_t* aBuffer,
|
||||
|
||||
nsPersistentProperties::nsPersistentProperties()
|
||||
: mIn(nullptr)
|
||||
, mTable(&property_HashTableOps, sizeof(PropertyTableEntry), 16)
|
||||
{
|
||||
PL_DHashTableInit(&mTable, &property_HashTableOps,
|
||||
sizeof(PropertyTableEntry), 16);
|
||||
|
||||
PL_INIT_ARENA_POOL(&mArena, "PersistentPropertyArena", 2048);
|
||||
}
|
||||
|
||||
nsPersistentProperties::~nsPersistentProperties()
|
||||
{
|
||||
PL_FinishArenaPool(&mArena);
|
||||
if (mTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mTable);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
||||
@@ -101,45 +101,20 @@ static const struct PLDHashTableOps nametable_CaseInsensitiveHashTableOps = {
|
||||
nullptr,
|
||||
};
|
||||
|
||||
nsStaticCaseInsensitiveNameTable::nsStaticCaseInsensitiveNameTable()
|
||||
nsStaticCaseInsensitiveNameTable::nsStaticCaseInsensitiveNameTable(
|
||||
const char* const aNames[], int32_t aLength)
|
||||
: mNameArray(nullptr)
|
||||
, mNameTable(&nametable_CaseInsensitiveHashTableOps,
|
||||
sizeof(NameTableEntry), aLength)
|
||||
, mNullStr("")
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsStaticCaseInsensitiveNameTable);
|
||||
}
|
||||
|
||||
nsStaticCaseInsensitiveNameTable::~nsStaticCaseInsensitiveNameTable()
|
||||
{
|
||||
if (mNameArray) {
|
||||
// manually call the destructor on placement-new'ed objects
|
||||
for (uint32_t index = 0; index < mNameTable.EntryCount(); index++) {
|
||||
mNameArray[index].~nsDependentCString();
|
||||
}
|
||||
free((void*)mNameArray);
|
||||
}
|
||||
if (mNameTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mNameTable);
|
||||
}
|
||||
MOZ_COUNT_DTOR(nsStaticCaseInsensitiveNameTable);
|
||||
}
|
||||
|
||||
bool
|
||||
nsStaticCaseInsensitiveNameTable::Init(const char* const aNames[],
|
||||
int32_t aLength)
|
||||
{
|
||||
NS_ASSERTION(!mNameArray, "double Init");
|
||||
NS_ASSERTION(!mNameTable.IsInitialized(), "double Init");
|
||||
NS_ASSERTION(aNames, "null name table");
|
||||
NS_ASSERTION(aLength, "0 length");
|
||||
MOZ_ASSERT(aNames, "null name table");
|
||||
MOZ_ASSERT(aLength, "0 length");
|
||||
|
||||
mNameArray = (nsDependentCString*)
|
||||
moz_xmalloc(aLength * sizeof(nsDependentCString));
|
||||
if (!mNameArray) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PL_DHashTableInit(&mNameTable, &nametable_CaseInsensitiveHashTableOps,
|
||||
sizeof(NameTableEntry), aLength);
|
||||
|
||||
for (int32_t index = 0; index < aLength; ++index) {
|
||||
const char* raw = aNames[index];
|
||||
@@ -149,10 +124,10 @@ nsStaticCaseInsensitiveNameTable::Init(const char* const aNames[],
|
||||
nsAutoCString temp1(raw);
|
||||
nsDependentCString temp2(raw);
|
||||
ToLowerCase(temp1);
|
||||
NS_ASSERTION(temp1.Equals(temp2), "upper case char in table");
|
||||
NS_ASSERTION(nsCRT::IsAscii(raw),
|
||||
"non-ascii string in table -- "
|
||||
"case-insensitive matching won't work right");
|
||||
MOZ_ASSERT(temp1.Equals(temp2), "upper case char in table");
|
||||
MOZ_ASSERT(nsCRT::IsAscii(raw),
|
||||
"non-ascii string in table -- "
|
||||
"case-insensitive matching won't work right");
|
||||
}
|
||||
#endif
|
||||
// use placement-new to initialize the string object
|
||||
@@ -175,14 +150,22 @@ nsStaticCaseInsensitiveNameTable::Init(const char* const aNames[],
|
||||
#ifdef DEBUG
|
||||
PL_DHashMarkTableImmutable(&mNameTable);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
nsStaticCaseInsensitiveNameTable::~nsStaticCaseInsensitiveNameTable()
|
||||
{
|
||||
// manually call the destructor on placement-new'ed objects
|
||||
for (uint32_t index = 0; index < mNameTable.EntryCount(); index++) {
|
||||
mNameArray[index].~nsDependentCString();
|
||||
}
|
||||
free((void*)mNameArray);
|
||||
MOZ_COUNT_DTOR(nsStaticCaseInsensitiveNameTable);
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsStaticCaseInsensitiveNameTable::Lookup(const nsACString& aName)
|
||||
{
|
||||
NS_ASSERTION(mNameArray, "not inited");
|
||||
NS_ASSERTION(mNameTable.IsInitialized(), "not inited");
|
||||
|
||||
const nsAFlatCString& str = PromiseFlatCString(aName);
|
||||
|
||||
@@ -197,7 +180,6 @@ int32_t
|
||||
nsStaticCaseInsensitiveNameTable::Lookup(const nsAString& aName)
|
||||
{
|
||||
NS_ASSERTION(mNameArray, "not inited");
|
||||
NS_ASSERTION(mNameTable.IsInitialized(), "not inited");
|
||||
|
||||
const nsAFlatString& str = PromiseFlatString(aName);
|
||||
|
||||
@@ -212,7 +194,6 @@ const nsAFlatCString&
|
||||
nsStaticCaseInsensitiveNameTable::GetStringValue(int32_t aIndex)
|
||||
{
|
||||
NS_ASSERTION(mNameArray, "not inited");
|
||||
NS_ASSERTION(mNameTable.IsInitialized(), "not inited");
|
||||
|
||||
if ((NOT_FOUND < aIndex) && ((uint32_t)aIndex < mNameTable.EntryCount())) {
|
||||
return mNameArray[aIndex];
|
||||
|
||||
@@ -33,17 +33,16 @@ class nsStaticCaseInsensitiveNameTable
|
||||
public:
|
||||
enum { NOT_FOUND = -1 };
|
||||
|
||||
bool Init(const char* const aNames[], int32_t aLength);
|
||||
int32_t Lookup(const nsACString& aName);
|
||||
int32_t Lookup(const nsAString& aName);
|
||||
const nsAFlatCString& GetStringValue(int32_t aIndex);
|
||||
|
||||
nsStaticCaseInsensitiveNameTable();
|
||||
nsStaticCaseInsensitiveNameTable(const char* const aNames[], int32_t aLength);
|
||||
~nsStaticCaseInsensitiveNameTable();
|
||||
|
||||
private:
|
||||
nsDependentCString* mNameArray;
|
||||
PLDHashTable mNameTable;
|
||||
PLDHashTable mNameTable;
|
||||
nsDependentCString mNullStr;
|
||||
};
|
||||
|
||||
|
||||
@@ -167,9 +167,6 @@ public:
|
||||
*/
|
||||
uint32_t EnumerateRead(EnumReadFunction aEnumFunc, void* aUserArg) const
|
||||
{
|
||||
NS_ASSERTION(this->mTable.IsInitialized(),
|
||||
"nsBaseHashtable was not initialized properly.");
|
||||
|
||||
s_EnumReadArgs enumData = { aEnumFunc, aUserArg };
|
||||
return PL_DHashTableEnumerate(const_cast<PLDHashTable*>(&this->mTable),
|
||||
s_EnumReadStub,
|
||||
@@ -199,9 +196,6 @@ public:
|
||||
*/
|
||||
uint32_t Enumerate(EnumFunction aEnumFunc, void* aUserArg)
|
||||
{
|
||||
NS_ASSERTION(this->mTable.IsInitialized(),
|
||||
"nsBaseHashtable was not initialized properly.");
|
||||
|
||||
s_EnumArgs enumData = { aEnumFunc, aUserArg };
|
||||
return PL_DHashTableEnumerate(&this->mTable,
|
||||
s_EnumStub,
|
||||
|
||||
+14
-37
@@ -87,8 +87,12 @@ class MOZ_NEEDS_NO_VTABLE_TYPE nsTHashtable
|
||||
public:
|
||||
// Separate constructors instead of default aInitLength parameter since
|
||||
// otherwise the default no-arg constructor isn't found.
|
||||
nsTHashtable() { Init(PL_DHASH_DEFAULT_INITIAL_LENGTH); }
|
||||
explicit nsTHashtable(uint32_t aInitLength) { Init(aInitLength); }
|
||||
nsTHashtable()
|
||||
: mTable(Ops(), sizeof(EntryType), PL_DHASH_DEFAULT_INITIAL_LENGTH)
|
||||
{}
|
||||
explicit nsTHashtable(uint32_t aInitLength)
|
||||
: mTable(Ops(), sizeof(EntryType), aInitLength)
|
||||
{}
|
||||
|
||||
/**
|
||||
* destructor, cleans up and deallocates
|
||||
@@ -127,9 +131,6 @@ public:
|
||||
*/
|
||||
EntryType* GetEntry(KeyType aKey) const
|
||||
{
|
||||
NS_ASSERTION(mTable.IsInitialized(),
|
||||
"nsTHashtable was not initialized properly.");
|
||||
|
||||
return static_cast<EntryType*>(
|
||||
PL_DHashTableSearch(const_cast<PLDHashTable*>(&mTable),
|
||||
EntryType::KeyToPointer(aKey)));
|
||||
@@ -150,9 +151,6 @@ public:
|
||||
*/
|
||||
EntryType* PutEntry(KeyType aKey)
|
||||
{
|
||||
NS_ASSERTION(mTable.IsInitialized(),
|
||||
"nsTHashtable was not initialized properly.");
|
||||
|
||||
return static_cast<EntryType*> // infallible add
|
||||
(PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey)));
|
||||
}
|
||||
@@ -160,9 +158,6 @@ public:
|
||||
MOZ_WARN_UNUSED_RESULT
|
||||
EntryType* PutEntry(KeyType aKey, const fallible_t&)
|
||||
{
|
||||
NS_ASSERTION(mTable.IsInitialized(),
|
||||
"nsTHashtable was not initialized properly.");
|
||||
|
||||
return static_cast<EntryType*>
|
||||
(PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey),
|
||||
mozilla::fallible));
|
||||
@@ -174,9 +169,6 @@ public:
|
||||
*/
|
||||
void RemoveEntry(KeyType aKey)
|
||||
{
|
||||
NS_ASSERTION(mTable.IsInitialized(),
|
||||
"nsTHashtable was not initialized properly.");
|
||||
|
||||
PL_DHashTableRemove(&mTable,
|
||||
EntryType::KeyToPointer(aKey));
|
||||
}
|
||||
@@ -215,9 +207,6 @@ public:
|
||||
*/
|
||||
uint32_t EnumerateEntries(Enumerator aEnumFunc, void* aUserArg)
|
||||
{
|
||||
NS_ASSERTION(mTable.IsInitialized(),
|
||||
"nsTHashtable was not initialized properly.");
|
||||
|
||||
s_EnumArgs args = { aEnumFunc, aUserArg };
|
||||
return PL_DHashTableEnumerate(&mTable, s_EnumStub, &args);
|
||||
}
|
||||
@@ -227,9 +216,6 @@ public:
|
||||
*/
|
||||
void Clear()
|
||||
{
|
||||
NS_ASSERTION(mTable.IsInitialized(),
|
||||
"nsTHashtable was not initialized properly.");
|
||||
|
||||
PL_DHashTableEnumerate(&mTable, PL_DHashStubEnumRemove, nullptr);
|
||||
}
|
||||
|
||||
@@ -317,9 +303,6 @@ public:
|
||||
*/
|
||||
void MarkImmutable()
|
||||
{
|
||||
NS_ASSERTION(mTable.IsInitialized(),
|
||||
"nsTHashtable was not initialized properly.");
|
||||
|
||||
PL_DHashMarkTableImmutable(&mTable);
|
||||
}
|
||||
#endif
|
||||
@@ -379,10 +362,9 @@ private:
|
||||
nsTHashtable(nsTHashtable<EntryType>& aToCopy) = delete;
|
||||
|
||||
/**
|
||||
* Initialize the table.
|
||||
* @param aInitLength the initial number of buckets in the hashtable
|
||||
* Gets the table's ops.
|
||||
*/
|
||||
void Init(uint32_t aInitLength);
|
||||
static const PLDHashTableOps* Ops();
|
||||
|
||||
/**
|
||||
* An implementation of SizeOfEntryExcludingThisFun that calls SizeOfExcludingThis()
|
||||
@@ -407,24 +389,20 @@ nsTHashtable<EntryType>::nsTHashtable(nsTHashtable<EntryType>&& aOther)
|
||||
// aOther shouldn't touch mTable after this, because we've stolen the table's
|
||||
// pointers but not overwitten them.
|
||||
MOZ_MAKE_MEM_UNDEFINED(&aOther.mTable, sizeof(aOther.mTable));
|
||||
|
||||
// Indicate that aOther is not initialized. This will make its destructor a
|
||||
// nop, which is what we want.
|
||||
aOther.mTable.SetOps(nullptr);
|
||||
}
|
||||
|
||||
template<class EntryType>
|
||||
nsTHashtable<EntryType>::~nsTHashtable()
|
||||
{
|
||||
if (mTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mTable);
|
||||
}
|
||||
}
|
||||
|
||||
template<class EntryType>
|
||||
void
|
||||
nsTHashtable<EntryType>::Init(uint32_t aInitLength)
|
||||
/* static */ const PLDHashTableOps*
|
||||
nsTHashtable<EntryType>::Ops()
|
||||
{
|
||||
// If this variable is a global variable, we get strange start-up failures on
|
||||
// WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a
|
||||
// function avoids that problem.
|
||||
static const PLDHashTableOps sOps =
|
||||
{
|
||||
s_HashKey,
|
||||
@@ -433,8 +411,7 @@ nsTHashtable<EntryType>::Init(uint32_t aInitLength)
|
||||
s_ClearEntry,
|
||||
s_InitEntry
|
||||
};
|
||||
|
||||
PL_DHashTableInit(&mTable, &sOps, sizeof(EntryType), aInitLength);
|
||||
return &sOps;
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
+17
-95
@@ -38,7 +38,7 @@
|
||||
* allowed (and therefore the level is 0 or 1, depending on whether they
|
||||
* incremented it).
|
||||
*
|
||||
* Only PL_DHashTableFinish needs to allow this special value.
|
||||
* Only Finish() needs to allow this special value.
|
||||
*/
|
||||
#define IMMUTABLE_RECURSION_LEVEL UINT32_MAX
|
||||
|
||||
@@ -169,22 +169,6 @@ SizeOfEntryStore(uint32_t aCapacity, uint32_t aEntrySize, uint32_t* aNbytes)
|
||||
return uint64_t(*aNbytes) == nbytes64; // returns false on overflow
|
||||
}
|
||||
|
||||
PLDHashTable*
|
||||
PL_NewDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength)
|
||||
{
|
||||
PLDHashTable* table = new PLDHashTable();
|
||||
PL_DHashTableInit(table, aOps, aEntrySize, aLength);
|
||||
return table;
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableDestroy(PLDHashTable* aTable)
|
||||
{
|
||||
PL_DHashTableFinish(aTable);
|
||||
delete aTable;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute max and min load numbers (entry counts). We have a secondary max
|
||||
* that allows us to overload a table reasonably if it cannot be grown further
|
||||
@@ -218,13 +202,6 @@ MOZ_ALWAYS_INLINE void
|
||||
PLDHashTable::Init(const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength)
|
||||
{
|
||||
MOZ_ASSERT(!IsInitialized());
|
||||
|
||||
// Check that the important fields have been set by the constructor.
|
||||
MOZ_ASSERT(mOps == nullptr);
|
||||
MOZ_ASSERT(mRecursionLevel == 0);
|
||||
MOZ_ASSERT(mEntryStore == nullptr);
|
||||
|
||||
if (aLength > PL_DHASH_MAX_INITIAL_LENGTH) {
|
||||
MOZ_CRASH("Initial length is too large");
|
||||
}
|
||||
@@ -259,28 +236,14 @@ PLDHashTable::Init(const PLDHashTableOps* aOps,
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableInit(PLDHashTable* aTable, const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength)
|
||||
PLDHashTable::PLDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength)
|
||||
{
|
||||
aTable->Init(aOps, aEntrySize, aLength);
|
||||
Init(aOps, aEntrySize, aLength);
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableInit(PLDHashTable2* aTable, const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength)
|
||||
{
|
||||
aTable->Init(aOps, aEntrySize, aLength);
|
||||
}
|
||||
|
||||
PLDHashTable2::PLDHashTable2(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength)
|
||||
: PLDHashTable()
|
||||
{
|
||||
PLDHashTable::Init(aOps, aEntrySize, aLength);
|
||||
}
|
||||
|
||||
PLDHashTable& PLDHashTable::operator=(PLDHashTable&& aOther)
|
||||
PLDHashTable&
|
||||
PLDHashTable::operator=(PLDHashTable&& aOther)
|
||||
{
|
||||
if (this == &aOther) {
|
||||
return *this;
|
||||
@@ -306,7 +269,6 @@ PLDHashTable& PLDHashTable::operator=(PLDHashTable&& aOther)
|
||||
#endif
|
||||
|
||||
// Clear up |aOther| so its destruction will be a no-op.
|
||||
aOther.mOps = nullptr;
|
||||
aOther.mEntryStore = nullptr;
|
||||
#ifdef DEBUG
|
||||
aOther.mRecursionLevel = 0;
|
||||
@@ -354,8 +316,7 @@ PLDHashTable::EntryIsFree(PLDHashEntryHdr* aEntry)
|
||||
MOZ_ALWAYS_INLINE void
|
||||
PLDHashTable::Finish()
|
||||
{
|
||||
if (!IsInitialized()) {
|
||||
MOZ_ASSERT(!mEntryStore);
|
||||
if (!mEntryStore) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -373,8 +334,6 @@ PLDHashTable::Finish()
|
||||
entryAddr += mEntrySize;
|
||||
}
|
||||
|
||||
mOps = nullptr;
|
||||
|
||||
DECREMENT_RECURSION_LEVEL(this);
|
||||
MOZ_ASSERT(RECURSION_LEVEL_SAFE_TO_FINISH(this));
|
||||
|
||||
@@ -383,38 +342,24 @@ PLDHashTable::Finish()
|
||||
mEntryStore = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableFinish(PLDHashTable* aTable)
|
||||
PLDHashTable::~PLDHashTable()
|
||||
{
|
||||
aTable->Finish();
|
||||
Finish();
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableFinish(PLDHashTable2* aTable)
|
||||
PLDHashTable::ClearAndPrepareForLength(uint32_t aLength)
|
||||
{
|
||||
aTable->Finish();
|
||||
}
|
||||
|
||||
PLDHashTable2::~PLDHashTable2()
|
||||
{
|
||||
PLDHashTable::Finish();
|
||||
}
|
||||
|
||||
void
|
||||
PLDHashTable2::ClearAndPrepareForLength(uint32_t aLength)
|
||||
{
|
||||
MOZ_ASSERT(IsInitialized());
|
||||
|
||||
// Get these values before the call to Finish() clobbers them.
|
||||
const PLDHashTableOps* ops = mOps;
|
||||
uint32_t entrySize = mEntrySize;
|
||||
|
||||
PLDHashTable::Finish();
|
||||
PLDHashTable::Init(ops, entrySize, aLength);
|
||||
Finish();
|
||||
Init(ops, entrySize, aLength);
|
||||
}
|
||||
|
||||
void
|
||||
PLDHashTable2::Clear()
|
||||
PLDHashTable::Clear()
|
||||
{
|
||||
ClearAndPrepareForLength(PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
}
|
||||
@@ -620,8 +565,6 @@ PLDHashTable::ComputeKeyHash(const void* aKey)
|
||||
MOZ_ALWAYS_INLINE PLDHashEntryHdr*
|
||||
PLDHashTable::Search(const void* aKey)
|
||||
{
|
||||
MOZ_ASSERT(IsInitialized());
|
||||
|
||||
INCREMENT_RECURSION_LEVEL(this);
|
||||
|
||||
METER(mStats.mSearches++);
|
||||
@@ -638,8 +581,6 @@ PLDHashTable::Search(const void* aKey)
|
||||
MOZ_ALWAYS_INLINE PLDHashEntryHdr*
|
||||
PLDHashTable::Add(const void* aKey, const mozilla::fallible_t&)
|
||||
{
|
||||
MOZ_ASSERT(IsInitialized());
|
||||
|
||||
PLDHashNumber keyHash;
|
||||
PLDHashEntryHdr* entry;
|
||||
uint32_t capacity;
|
||||
@@ -745,8 +686,6 @@ PLDHashTable::Add(const void* aKey)
|
||||
MOZ_ALWAYS_INLINE void
|
||||
PLDHashTable::Remove(const void* aKey)
|
||||
{
|
||||
MOZ_ASSERT(IsInitialized());
|
||||
|
||||
MOZ_ASSERT(mRecursionLevel == 0);
|
||||
INCREMENT_RECURSION_LEVEL(this);
|
||||
|
||||
@@ -801,7 +740,6 @@ PL_DHashTableRemove(PLDHashTable* aTable, const void* aKey)
|
||||
MOZ_ALWAYS_INLINE void
|
||||
PLDHashTable::RawRemove(PLDHashEntryHdr* aEntry)
|
||||
{
|
||||
MOZ_ASSERT(IsInitialized());
|
||||
MOZ_ASSERT(mEntryStore);
|
||||
|
||||
MOZ_ASSERT(mRecursionLevel != IMMUTABLE_RECURSION_LEVEL);
|
||||
@@ -830,8 +768,6 @@ PL_DHashTableRawRemove(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
|
||||
MOZ_ALWAYS_INLINE uint32_t
|
||||
PLDHashTable::Enumerate(PLDHashEnumerator aEtor, void* aArg)
|
||||
{
|
||||
MOZ_ASSERT(IsInitialized());
|
||||
|
||||
if (!mEntryStore) {
|
||||
return 0;
|
||||
}
|
||||
@@ -940,8 +876,6 @@ PLDHashTable::SizeOfExcludingThis(
|
||||
PLDHashSizeOfEntryExcludingThisFun aSizeOfEntryExcludingThis,
|
||||
MallocSizeOf aMallocSizeOf, void* aArg /* = nullptr */) const
|
||||
{
|
||||
MOZ_ASSERT(IsInitialized());
|
||||
|
||||
if (!mEntryStore) {
|
||||
return 0;
|
||||
}
|
||||
@@ -964,8 +898,6 @@ PLDHashTable::SizeOfIncludingThis(
|
||||
PLDHashSizeOfEntryExcludingThisFun aSizeOfEntryExcludingThis,
|
||||
MallocSizeOf aMallocSizeOf, void* aArg /* = nullptr */) const
|
||||
{
|
||||
MOZ_ASSERT(IsInitialized());
|
||||
|
||||
return aMallocSizeOf(this) +
|
||||
SizeOfExcludingThis(aSizeOfEntryExcludingThis, aMallocSizeOf, aArg);
|
||||
}
|
||||
@@ -995,8 +927,6 @@ PLDHashTable::Iterator::Iterator(const PLDHashTable* aTable)
|
||||
mEntryAddr(mTable->mEntryStore),
|
||||
mEntryOffset(0)
|
||||
{
|
||||
MOZ_ASSERT(mTable->IsInitialized());
|
||||
|
||||
// Make sure that modifications can't simultaneously happen while the iterator
|
||||
// is active.
|
||||
INCREMENT_RECURSION_LEVEL(mTable);
|
||||
@@ -1025,8 +955,6 @@ PLDHashTable::Iterator::Iterator(const Iterator& aIterator)
|
||||
mEntryAddr(aIterator.mEntryAddr),
|
||||
mEntryOffset(aIterator.mEntryOffset)
|
||||
{
|
||||
MOZ_ASSERT(mTable->IsInitialized());
|
||||
|
||||
// We need the copy constructor only so that we can keep the recursion level
|
||||
// consistent.
|
||||
INCREMENT_RECURSION_LEVEL(mTable);
|
||||
@@ -1034,15 +962,12 @@ PLDHashTable::Iterator::Iterator(const Iterator& aIterator)
|
||||
|
||||
PLDHashTable::Iterator::~Iterator()
|
||||
{
|
||||
MOZ_ASSERT(mTable->IsInitialized());
|
||||
|
||||
DECREMENT_RECURSION_LEVEL(mTable);
|
||||
}
|
||||
|
||||
bool PLDHashTable::Iterator::HasMoreEntries() const
|
||||
bool
|
||||
PLDHashTable::Iterator::HasMoreEntries() const
|
||||
{
|
||||
MOZ_ASSERT(mTable->IsInitialized());
|
||||
|
||||
// Check the number of live entries seen, not the total number of entries
|
||||
// seen. To see why, consider what happens if the last entry is not live: we
|
||||
// would have to iterate after returning an entry to see if more live entries
|
||||
@@ -1050,7 +975,8 @@ bool PLDHashTable::Iterator::HasMoreEntries() const
|
||||
return mEntryOffset < mTable->EntryCount();
|
||||
}
|
||||
|
||||
PLDHashEntryHdr* PLDHashTable::Iterator::NextEntry()
|
||||
PLDHashEntryHdr*
|
||||
PLDHashTable::Iterator::NextEntry()
|
||||
{
|
||||
MOZ_ASSERT(HasMoreEntries());
|
||||
|
||||
@@ -1094,8 +1020,6 @@ PLDHashEntryHdr* PLDHashTable::Iterator::NextEntry()
|
||||
MOZ_ALWAYS_INLINE void
|
||||
PLDHashTable::MarkImmutable()
|
||||
{
|
||||
MOZ_ASSERT(IsInitialized());
|
||||
|
||||
mRecursionLevel = IMMUTABLE_RECURSION_LEVEL;
|
||||
}
|
||||
|
||||
@@ -1112,8 +1036,6 @@ PL_DHashMarkTableImmutable(PLDHashTable* aTable)
|
||||
void
|
||||
PLDHashTable::DumpMeter(PLDHashEnumerator aDump, FILE* aFp)
|
||||
{
|
||||
MOZ_ASSERT(IsInitialized());
|
||||
|
||||
PLDHashNumber hash1, hash2, maxChainHash1, maxChainHash2;
|
||||
double sqsum, mean, variance, sigma;
|
||||
PLDHashEntryHdr* entry;
|
||||
|
||||
+29
-122
@@ -161,8 +161,6 @@ typedef size_t (*PLDHashSizeOfEntryExcludingThisFun)(
|
||||
*/
|
||||
class PLDHashTable
|
||||
{
|
||||
friend class PLDHashTable2;
|
||||
|
||||
private:
|
||||
const PLDHashTableOps* mOps; /* Virtual operations; see below. */
|
||||
int16_t mHashShift; /* multiplicative hash shift */
|
||||
@@ -204,24 +202,16 @@ private:
|
||||
#endif
|
||||
|
||||
public:
|
||||
// The most important thing here is that we zero |mOps| because it's used to
|
||||
// determine if Init() has been called. (The use of MOZ_CONSTEXPR means all
|
||||
// the other members must be initialized too.)
|
||||
MOZ_CONSTEXPR PLDHashTable()
|
||||
: mOps(nullptr)
|
||||
, mHashShift(0)
|
||||
, mEntrySize(0)
|
||||
, mEntryCount(0)
|
||||
, mRemovedCount(0)
|
||||
, mGeneration(0)
|
||||
, mEntryStore(nullptr)
|
||||
#ifdef PL_DHASHMETER
|
||||
, mStats()
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
, mRecursionLevel()
|
||||
#endif
|
||||
{}
|
||||
// Initialize the table with |aOps| and |aEntrySize|. The table's initial
|
||||
// capacity is chosen such that |aLength| elements can be inserted without
|
||||
// rehashing; if |aLength| is a power-of-two, this capacity will be
|
||||
// |2*length|. However, because entry storage is allocated lazily, this
|
||||
// initial capacity won't be relevant until the first element is added; prior
|
||||
// to that the capacity will be zero.
|
||||
//
|
||||
// This will crash if |aEntrySize| and/or |aLength| are too large.
|
||||
PLDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
PLDHashTable(PLDHashTable&& aOther)
|
||||
: mOps(nullptr)
|
||||
@@ -235,11 +225,10 @@ public:
|
||||
|
||||
PLDHashTable& operator=(PLDHashTable&& aOther);
|
||||
|
||||
bool IsInitialized() const { return !!mOps; }
|
||||
~PLDHashTable();
|
||||
|
||||
// These should be used rarely.
|
||||
// This should be used rarely.
|
||||
const PLDHashTableOps* const Ops() { return mOps; }
|
||||
void SetOps(const PLDHashTableOps* aOps) { mOps = aOps; }
|
||||
|
||||
/*
|
||||
* Size in entries (gross, not net of free and removed sentinels) for table.
|
||||
@@ -255,10 +244,6 @@ public:
|
||||
uint32_t EntryCount() const { return mEntryCount; }
|
||||
uint32_t Generation() const { return mGeneration; }
|
||||
|
||||
void Init(const PLDHashTableOps* aOps, uint32_t aEntrySize, uint32_t aLength);
|
||||
|
||||
void Finish();
|
||||
|
||||
PLDHashEntryHdr* Search(const void* aKey);
|
||||
PLDHashEntryHdr* Add(const void* aKey, const mozilla::fallible_t&);
|
||||
PLDHashEntryHdr* Add(const void* aKey);
|
||||
@@ -268,6 +253,20 @@ public:
|
||||
|
||||
uint32_t Enumerate(PLDHashEnumerator aEtor, void* aArg);
|
||||
|
||||
// This function is equivalent to
|
||||
// ClearAndPrepareForLength(PL_DHASH_DEFAULT_INITIAL_LENGTH).
|
||||
void Clear();
|
||||
|
||||
// This function clears the table's contents and frees its entry storage,
|
||||
// leaving it in a empty state ready to be used again. Afterwards, when the
|
||||
// first element is added the entry storage that gets allocated will have a
|
||||
// capacity large enough to fit |aLength| elements without rehashing.
|
||||
//
|
||||
// It's conceptually the same as calling the destructor and then re-calling
|
||||
// the constructor with the original |aOps| and |aEntrySize| arguments, and
|
||||
// a new |aLength| argument.
|
||||
void ClearAndPrepareForLength(uint32_t aLength);
|
||||
|
||||
size_t SizeOfIncludingThis(
|
||||
PLDHashSizeOfEntryExcludingThisFun aSizeOfEntryExcludingThis,
|
||||
mozilla::MallocSizeOf aMallocSizeOf, void* aArg = nullptr) const;
|
||||
@@ -323,6 +322,9 @@ private:
|
||||
|
||||
PLDHashNumber ComputeKeyHash(const void* aKey);
|
||||
|
||||
void Init(const PLDHashTableOps* aOps, uint32_t aEntrySize, uint32_t aLength);
|
||||
void Finish();
|
||||
|
||||
enum SearchReason { ForSearchOrRemove, ForAdd };
|
||||
|
||||
template <SearchReason Reason>
|
||||
@@ -337,61 +339,6 @@ private:
|
||||
PLDHashTable& operator=(const PLDHashTable& aOther) = delete;
|
||||
};
|
||||
|
||||
// PLDHashTable uses C style, manual initialization and finalization, via the
|
||||
// Init() and Finish() methods. PLDHashTable2 is a slight extension of
|
||||
// PLDHashTable that provides C++-style, automatic initialization and
|
||||
// finalization via an initializing constructor and a destructor. It also
|
||||
// overrides the Init() and Finish() methods with versions that will crash
|
||||
// immediately if called.
|
||||
//
|
||||
// XXX: We're using a subclass here so that instances of PLDHashTable can be
|
||||
// converted incrementally to PLDHashTable2. Once all instances have been
|
||||
// converted, we can merge the two and call the merged class PLDHashTable
|
||||
// again.
|
||||
class PLDHashTable2 : public PLDHashTable
|
||||
{
|
||||
public:
|
||||
PLDHashTable2(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
PLDHashTable2(PLDHashTable2&& aOther)
|
||||
: PLDHashTable(mozilla::Move(aOther))
|
||||
{}
|
||||
|
||||
PLDHashTable2& operator=(PLDHashTable2&& aOther)
|
||||
{
|
||||
return static_cast<PLDHashTable2&>(
|
||||
PLDHashTable::operator=(mozilla::Move(aOther)));
|
||||
}
|
||||
|
||||
~PLDHashTable2();
|
||||
|
||||
void Init(const PLDHashTableOps* aOps, uint32_t aEntrySize, uint32_t aLength)
|
||||
{
|
||||
MOZ_CRASH("PLDHashTable2::Init()");
|
||||
}
|
||||
|
||||
void Finish() { MOZ_CRASH("PLDHashTable2::Finish()"); }
|
||||
|
||||
// This function is equivalent to
|
||||
// ClearAndPrepareForLength(PL_DHASH_DEFAULT_INITIAL_LENGTH).
|
||||
void Clear();
|
||||
|
||||
// This function clears the table's contents and frees its entry storage,
|
||||
// leaving it in a empty state ready to be used again. Afterwards, when the
|
||||
// first element is added the entry storage that gets allocated will have a
|
||||
// capacity large enough to fit |aLength| elements without rehashing.
|
||||
//
|
||||
// It's conceptually the same as calling the destructor and then re-calling
|
||||
// the constructor with the original |aOps| and |aEntrySize| arguments, and
|
||||
// a new |aLength| argument.
|
||||
void ClearAndPrepareForLength(uint32_t aLength);
|
||||
|
||||
private:
|
||||
PLDHashTable2(const PLDHashTable2& aOther) = delete;
|
||||
PLDHashTable2& operator=(const PLDHashTable2& aOther) = delete;
|
||||
};
|
||||
|
||||
/*
|
||||
* Compute the hash code for a given key to be looked up, added, or removed
|
||||
* from aTable. A hash code may have any PLDHashNumber value.
|
||||
@@ -505,46 +452,6 @@ void PL_DHashFreeStringKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
|
||||
*/
|
||||
const PLDHashTableOps* PL_DHashGetStubOps(void);
|
||||
|
||||
/*
|
||||
* Dynamically allocate a new PLDHashTable, initialize it using
|
||||
* PL_DHashTableInit, and return its address. Never returns null.
|
||||
*/
|
||||
PLDHashTable* PL_NewDHashTable(
|
||||
const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
/*
|
||||
* Free |aTable|'s entry storage and |aTable| itself (both via
|
||||
* aTable->mOps->freeTable). Use this function to destroy a PLDHashTable that
|
||||
* was allocated on the heap via PL_NewDHashTable().
|
||||
*/
|
||||
void PL_DHashTableDestroy(PLDHashTable* aTable);
|
||||
|
||||
/*
|
||||
* Initialize aTable with aOps and aEntrySize. The table's initial capacity
|
||||
* will be chosen such that |aLength| elements can be inserted without
|
||||
* rehashing; if |aLength| is a power-of-two, this capacity will be |2*length|.
|
||||
* However, because entry storage is allocated lazily, this initial capacity
|
||||
* won't be relevant until the first element is added; prior to that the
|
||||
* capacity will be zero.
|
||||
*
|
||||
* This function will crash if |aEntrySize| and/or |aLength| are too large.
|
||||
*/
|
||||
void PL_DHashTableInit(
|
||||
PLDHashTable* aTable, const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
void PL_DHashTableInit(
|
||||
PLDHashTable2* aTable, const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
/*
|
||||
* Free |aTable|'s entry storage (via aTable->mOps->freeTable). Use this
|
||||
* function to destroy a PLDHashTable that is allocated on the stack or in
|
||||
* static memory and was created via PL_DHashTableInit().
|
||||
*/
|
||||
void PL_DHashTableFinish(PLDHashTable* aTable);
|
||||
void PL_DHashTableFinish(PLDHashTable2* aTable);
|
||||
|
||||
/*
|
||||
* To search for a key in |table|, call:
|
||||
*
|
||||
|
||||
+18
-52
@@ -14,13 +14,6 @@ namespace TestPLDHash {
|
||||
|
||||
static bool test_pldhash_Init_capacity_ok()
|
||||
{
|
||||
PLDHashTable t;
|
||||
|
||||
// Check that the constructor nulls |ops|.
|
||||
if (t.IsInitialized()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try the largest allowed capacity. With PL_DHASH_MAX_CAPACITY==1<<26, this
|
||||
// would allocate (if we added an element) 0.5GB of entry store on 32-bit
|
||||
// platforms and 1GB on 64-bit platforms.
|
||||
@@ -34,35 +27,20 @@ static bool test_pldhash_Init_capacity_ok()
|
||||
// of entry storage. That's very likely to fail on 32-bit platforms, so such
|
||||
// a test wouldn't be reliable.
|
||||
//
|
||||
PL_DHashTableInit(&t, PL_DHashGetStubOps(), sizeof(PLDHashEntryStub),
|
||||
PL_DHASH_MAX_INITIAL_LENGTH);
|
||||
|
||||
// Check that Init() sets |ops|.
|
||||
if (!t.IsInitialized()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that Finish() nulls |ops|.
|
||||
PL_DHashTableFinish(&t);
|
||||
if (t.IsInitialized()) {
|
||||
return false;
|
||||
}
|
||||
PLDHashTable t(PL_DHashGetStubOps(), sizeof(PLDHashEntryStub),
|
||||
PL_DHASH_MAX_INITIAL_LENGTH);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool test_pldhash_lazy_storage()
|
||||
{
|
||||
PLDHashTable2 t(PL_DHashGetStubOps(), sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t(PL_DHashGetStubOps(), sizeof(PLDHashEntryStub));
|
||||
|
||||
// PLDHashTable allocates entry storage lazily. Check that all the non-add
|
||||
// operations work appropriately when the table is empty and the storage
|
||||
// hasn't yet been allocated.
|
||||
|
||||
if (!t.IsInitialized()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t.Capacity() != 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -128,37 +106,31 @@ static const PLDHashTableOps trivialOps = {
|
||||
|
||||
static bool test_pldhash_move_semantics()
|
||||
{
|
||||
PLDHashTable2 t1(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t1(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PL_DHashTableAdd(&t1, (const void*)88);
|
||||
PLDHashTable2 t2(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t2(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PL_DHashTableAdd(&t2, (const void*)99);
|
||||
|
||||
t1 = mozilla::Move(t1); // self-move
|
||||
|
||||
t1 = mozilla::Move(t2); // inited overwritten with inited
|
||||
t1 = mozilla::Move(t2); // empty overwritten with empty
|
||||
|
||||
PLDHashTable t3, t4;
|
||||
PL_DHashTableInit(&t3, &trivialOps, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t3(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t4(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PL_DHashTableAdd(&t3, (const void*)88);
|
||||
|
||||
t3 = mozilla::Move(t4); // inited overwritten with uninited
|
||||
t3 = mozilla::Move(t4); // non-empty overwritten with empty
|
||||
|
||||
PL_DHashTableFinish(&t3);
|
||||
PL_DHashTableFinish(&t4);
|
||||
|
||||
PLDHashTable t5, t6;
|
||||
PL_DHashTableInit(&t6, &trivialOps, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t5(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t6(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PL_DHashTableAdd(&t6, (const void*)88);
|
||||
|
||||
t5 = mozilla::Move(t6); // uninited overwritten with inited
|
||||
t5 = mozilla::Move(t6); // empty overwritten with non-empty
|
||||
|
||||
PL_DHashTableFinish(&t5);
|
||||
PL_DHashTableFinish(&t6);
|
||||
PLDHashTable t7(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t8(mozilla::Move(t7)); // new table constructed with uninited
|
||||
|
||||
PLDHashTable t7;
|
||||
PLDHashTable t8(mozilla::Move(t7)); // new table constructed with uninited
|
||||
|
||||
PLDHashTable2 t9(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t9(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PL_DHashTableAdd(&t9, (const void*)88);
|
||||
PLDHashTable t10(mozilla::Move(t9)); // new table constructed with inited
|
||||
|
||||
@@ -167,7 +139,7 @@ static bool test_pldhash_move_semantics()
|
||||
|
||||
static bool test_pldhash_Clear()
|
||||
{
|
||||
PLDHashTable2 t1(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t1(&trivialOps, sizeof(PLDHashEntryStub));
|
||||
|
||||
t1.Clear();
|
||||
if (t1.EntryCount() != 0) {
|
||||
@@ -213,14 +185,8 @@ static bool test_pldhash_Clear()
|
||||
static bool test_pldhash_grow_to_max_capacity()
|
||||
{
|
||||
// This is infallible.
|
||||
PLDHashTable2* t =
|
||||
new PLDHashTable2(&trivialOps, sizeof(PLDHashEntryStub), 128);
|
||||
|
||||
// Check that New() sets |t->ops|.
|
||||
if (!t->IsInitialized()) {
|
||||
delete t;
|
||||
return false;
|
||||
}
|
||||
PLDHashTable* t =
|
||||
new PLDHashTable(&trivialOps, sizeof(PLDHashEntryStub), 128);
|
||||
|
||||
// Keep inserting elements until failure occurs because the table is full.
|
||||
size_t numInserted = 0;
|
||||
|
||||
Reference in New Issue
Block a user