зеркало из https://github.com/mozilla/gecko-dev.git
Bug 730825 - Part 1: change content/ to use nsTHashtable instead of nsDoubleHashtable; r=sicking
This commit is contained in:
Родитель
a2019bab87
Коммит
e6e610c92e
|
@ -41,7 +41,6 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsDoubleHashtable.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIChannel.h"
|
||||
|
|
|
@ -55,7 +55,8 @@
|
|||
|
||||
#include "txList.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsDoubleHashtable.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsBaseHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "txCore.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
@ -229,24 +230,7 @@ class NodeDefinition : public Node
|
|||
//Definition and Implementation of a Document.
|
||||
//
|
||||
|
||||
/**
|
||||
* nsDoubleHashtable definitions for IDs
|
||||
*
|
||||
* It may be possible to share the key value with the element,
|
||||
* but that may leave entries without keys, as the entries
|
||||
* are constructed from the key value and the setting of mElement
|
||||
* happens late. As pldhash.h ain't clear on this, we store the
|
||||
* key by inheriting from PLDHashStringEntry.
|
||||
*/
|
||||
class txIDEntry : public PLDHashStringEntry
|
||||
{
|
||||
public:
|
||||
txIDEntry(const void* aKey) : PLDHashStringEntry(aKey), mElement(nsnull)
|
||||
{
|
||||
}
|
||||
Element* mElement;
|
||||
};
|
||||
DECL_DHASH_WRAPPER(txIDMap, txIDEntry, nsAString&)
|
||||
typedef nsTHashtable<nsBaseHashtableET<nsStringHashKey, Element*> > txIDMap;
|
||||
|
||||
class Document : public NodeDefinition
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#ifndef txKey_h__
|
||||
#define txKey_h__
|
||||
|
||||
#include "nsDoubleHashtable.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "txNodeSet.h"
|
||||
#include "txList.h"
|
||||
#include "txXSLTPatterns.h"
|
||||
|
@ -68,21 +68,31 @@ public:
|
|||
|
||||
struct txKeyValueHashEntry : public PLDHashEntryHdr
|
||||
{
|
||||
txKeyValueHashEntry(const void* aKey)
|
||||
: mKey(*static_cast<const txKeyValueHashKey*>(aKey)),
|
||||
mNodeSet(new txNodeSet(nsnull))
|
||||
{
|
||||
}
|
||||
public:
|
||||
typedef const txKeyValueHashKey& KeyType;
|
||||
typedef const txKeyValueHashKey* KeyTypePointer;
|
||||
|
||||
// @see nsDoubleHashtable.h
|
||||
bool MatchEntry(const void* aKey) const;
|
||||
static PLDHashNumber HashKey(const void* aKey);
|
||||
txKeyValueHashEntry(KeyTypePointer aKey)
|
||||
: mKey(*aKey),
|
||||
mNodeSet(new txNodeSet(nsnull)) { }
|
||||
|
||||
txKeyValueHashEntry(const txKeyValueHashEntry& entry)
|
||||
: mKey(entry.mKey),
|
||||
mNodeSet(entry.mNodeSet) { }
|
||||
|
||||
bool KeyEquals(KeyTypePointer aKey) const;
|
||||
|
||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
|
||||
|
||||
static PLDHashNumber HashKey(KeyTypePointer aKey);
|
||||
|
||||
enum { ALLOW_MEMMOVE = true };
|
||||
|
||||
txKeyValueHashKey mKey;
|
||||
nsRefPtr<txNodeSet> mNodeSet;
|
||||
};
|
||||
|
||||
DECL_DHASH_WRAPPER(txKeyValueHash, txKeyValueHashEntry, txKeyValueHashKey&)
|
||||
typedef nsTHashtable<txKeyValueHashEntry> txKeyValueHash;
|
||||
|
||||
class txIndexedKeyHashKey
|
||||
{
|
||||
|
@ -100,22 +110,31 @@ public:
|
|||
|
||||
struct txIndexedKeyHashEntry : public PLDHashEntryHdr
|
||||
{
|
||||
txIndexedKeyHashEntry(const void* aKey)
|
||||
: mKey(*static_cast<const txIndexedKeyHashKey*>(aKey)),
|
||||
mIndexed(false)
|
||||
{
|
||||
}
|
||||
public:
|
||||
typedef const txIndexedKeyHashKey& KeyType;
|
||||
typedef const txIndexedKeyHashKey* KeyTypePointer;
|
||||
|
||||
// @see nsDoubleHashtable.h
|
||||
bool MatchEntry(const void* aKey) const;
|
||||
static PLDHashNumber HashKey(const void* aKey);
|
||||
txIndexedKeyHashEntry(KeyTypePointer aKey)
|
||||
: mKey(*aKey),
|
||||
mIndexed(false) { }
|
||||
|
||||
txIndexedKeyHashEntry(const txIndexedKeyHashEntry& entry)
|
||||
: mKey(entry.mKey),
|
||||
mIndexed(entry.mIndexed) { }
|
||||
|
||||
bool KeyEquals(KeyTypePointer aKey) const;
|
||||
|
||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
|
||||
|
||||
static PLDHashNumber HashKey(KeyTypePointer aKey);
|
||||
|
||||
enum { ALLOW_MEMMOVE = true };
|
||||
|
||||
txIndexedKeyHashKey mKey;
|
||||
bool mIndexed;
|
||||
};
|
||||
|
||||
DECL_DHASH_WRAPPER(txIndexedKeyHash, txIndexedKeyHashEntry,
|
||||
txIndexedKeyHashKey&)
|
||||
typedef nsTHashtable<txIndexedKeyHashEntry> txIndexedKeyHash;
|
||||
|
||||
/**
|
||||
* Class holding all <xsl:key>s of a particular expanded name in the
|
||||
|
|
|
@ -152,51 +152,36 @@ txKeyFunctionCall::getNameAtom(nsIAtom** aAtom)
|
|||
* Hash functions
|
||||
*/
|
||||
|
||||
DHASH_WRAPPER(txKeyValueHash, txKeyValueHashEntry, txKeyValueHashKey&)
|
||||
DHASH_WRAPPER(txIndexedKeyHash, txIndexedKeyHashEntry, txIndexedKeyHashKey&)
|
||||
|
||||
bool
|
||||
txKeyValueHashEntry::MatchEntry(const void* aKey) const
|
||||
txKeyValueHashEntry::KeyEquals(KeyTypePointer aKey) const
|
||||
{
|
||||
const txKeyValueHashKey* key =
|
||||
static_cast<const txKeyValueHashKey*>(aKey);
|
||||
|
||||
return mKey.mKeyName == key->mKeyName &&
|
||||
mKey.mRootIdentifier == key->mRootIdentifier &&
|
||||
mKey.mKeyValue.Equals(key->mKeyValue);
|
||||
return mKey.mKeyName == aKey->mKeyName &&
|
||||
mKey.mRootIdentifier == aKey->mRootIdentifier &&
|
||||
mKey.mKeyValue.Equals(aKey->mKeyValue);
|
||||
}
|
||||
|
||||
PLDHashNumber
|
||||
txKeyValueHashEntry::HashKey(const void* aKey)
|
||||
txKeyValueHashEntry::HashKey(KeyTypePointer aKey)
|
||||
{
|
||||
const txKeyValueHashKey* key =
|
||||
static_cast<const txKeyValueHashKey*>(aKey);
|
||||
|
||||
return key->mKeyName.mNamespaceID ^
|
||||
NS_PTR_TO_INT32(key->mKeyName.mLocalName.get()) ^
|
||||
key->mRootIdentifier ^
|
||||
HashString(key->mKeyValue);
|
||||
return aKey->mKeyName.mNamespaceID ^
|
||||
NS_PTR_TO_INT32(aKey->mKeyName.mLocalName.get()) ^
|
||||
aKey->mRootIdentifier ^
|
||||
HashString(aKey->mKeyValue);
|
||||
}
|
||||
|
||||
bool
|
||||
txIndexedKeyHashEntry::MatchEntry(const void* aKey) const
|
||||
txIndexedKeyHashEntry::KeyEquals(KeyTypePointer aKey) const
|
||||
{
|
||||
const txIndexedKeyHashKey* key =
|
||||
static_cast<const txIndexedKeyHashKey*>(aKey);
|
||||
|
||||
return mKey.mKeyName == key->mKeyName &&
|
||||
mKey.mRootIdentifier == key->mRootIdentifier;
|
||||
return mKey.mKeyName == aKey->mKeyName &&
|
||||
mKey.mRootIdentifier == aKey->mRootIdentifier;
|
||||
}
|
||||
|
||||
PLDHashNumber
|
||||
txIndexedKeyHashEntry::HashKey(const void* aKey)
|
||||
txIndexedKeyHashEntry::HashKey(KeyTypePointer aKey)
|
||||
{
|
||||
const txIndexedKeyHashKey* key =
|
||||
static_cast<const txIndexedKeyHashKey*>(aKey);
|
||||
|
||||
return key->mKeyName.mNamespaceID ^
|
||||
NS_PTR_TO_INT32(key->mKeyName.mLocalName.get()) ^
|
||||
key->mRootIdentifier;
|
||||
return aKey->mKeyName.mNamespaceID ^
|
||||
NS_PTR_TO_INT32(aKey->mKeyName.mLocalName.get()) ^
|
||||
aKey->mRootIdentifier;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -211,9 +196,6 @@ txKeyHash::getKeyNodes(const txExpandedName& aKeyName,
|
|||
txExecutionState& aEs,
|
||||
txNodeSet** aResult)
|
||||
{
|
||||
NS_ENSURE_TRUE(mKeyValues.mHashTable.ops && mIndexedKeys.mHashTable.ops,
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
PRInt32 identifier = txXPathNodeUtils::getUniqueIdentifier(aRoot);
|
||||
|
@ -241,7 +223,7 @@ txKeyHash::getKeyNodes(const txExpandedName& aKeyName,
|
|||
}
|
||||
|
||||
txIndexedKeyHashKey indexKey(aKeyName, identifier);
|
||||
txIndexedKeyHashEntry* indexEntry = mIndexedKeys.AddEntry(indexKey);
|
||||
txIndexedKeyHashEntry* indexEntry = mIndexedKeys.PutEntry(indexKey);
|
||||
NS_ENSURE_TRUE(indexEntry, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (indexEntry->mIndexed) {
|
||||
|
@ -412,7 +394,7 @@ nsresult txXSLKey::testNode(const txXPathNode& aNode,
|
|||
txXPathNodeUtils::appendNodeValue(res->get(i), val);
|
||||
|
||||
aKey.mKeyValue.Assign(val);
|
||||
txKeyValueHashEntry* entry = aKeyValueHash.AddEntry(aKey);
|
||||
txKeyValueHashEntry* entry = aKeyValueHash.PutEntry(aKey);
|
||||
NS_ENSURE_TRUE(entry && entry->mNodeSet,
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
@ -427,7 +409,7 @@ nsresult txXSLKey::testNode(const txXPathNode& aNode,
|
|||
exprResult->stringValue(val);
|
||||
|
||||
aKey.mKeyValue.Assign(val);
|
||||
txKeyValueHashEntry* entry = aKeyValueHash.AddEntry(aKey);
|
||||
txKeyValueHashEntry* entry = aKeyValueHash.PutEntry(aKey);
|
||||
NS_ENSURE_TRUE(entry && entry->mNodeSet,
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче