Bug 177179

slightly optimize inDOMView::GetNodeTypeKey
r=timeless/jkeiser sr=bzbarsky a=roc+moz
This commit is contained in:
caillon%returnzero.com 2002-10-31 15:25:52 +00:00
parent e0661af41f
commit 6865d45b89
2 changed files with 9 additions and 15 deletions

View File

@ -265,8 +265,7 @@ inDOMView::AddFilterByType(PRUint16 aType, PRBool aExclusive)
NS_IMETHODIMP
inDOMView::RemoveFilterByType(PRUint16 aType)
{
PRUint16 key = GetNodeTypeKey(aType);
mFilters -= key;
mFilters &= ~(GetNodeTypeKey(aType));
return NS_OK;
}
@ -1265,13 +1264,3 @@ inDOMView::AppendAttrsToArray(nsIDOMNamedNodeMap* aKids, nsISupportsArray* aArra
}
return NS_OK;
}
PRUint16
inDOMView::GetNodeTypeKey(PRUint16 aType)
{
PRUint16 key = 1;
for (PRUint32 i = 0; i < aType; ++i)
key = key * 2;
return key;
}

View File

@ -134,8 +134,8 @@ protected:
nsCOMPtr<nsITreeBoxObject> mTree;
nsCOMPtr<nsITreeSelection> mSelection;
PRBool mShowAnonymous;
PRBool mShowSubDocuments;
PRPackedBool mShowAnonymous;
PRPackedBool mShowSubDocuments;
PRUint32 mFilters;
nsCOMPtr<nsIDOMNode> mRootNode;
@ -165,7 +165,12 @@ protected:
void RemoveLink(inDOMViewNode* aNode);
void ReplaceLink(inDOMViewNode* aNewNode, inDOMViewNode* aOldNode);
PRUint16 GetNodeTypeKey(PRUint16 aType);
inline PRUint16 GetNodeTypeKey(PRUint16 aType)
{
NS_ASSERTION(aType < 16, "You doofus");
return 1 << aType;
};
nsresult GetChildNodesFor(nsIDOMNode* aNode, nsISupportsArray **aResult);
nsresult AppendKidsToArray(nsIDOMNodeList* aKids, nsISupportsArray* aArray);
nsresult AppendAttrsToArray(nsIDOMNamedNodeMap* aKids, nsISupportsArray* aArray);