Bug 564569. Speed up the cache-hit case of getElementsBy(Class)Name. r=jst
This commit is contained in:
@@ -2291,6 +2291,13 @@ nsHTMLDocument::MatchNameAttribute(nsIContent* aContent, PRInt32 aNamespaceID,
|
||||
*elementName, eCaseMatters);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void*
|
||||
nsHTMLDocument::UseExistingNameString(nsINode* aRootNode, const nsString* aName)
|
||||
{
|
||||
return const_cast<nsString*>(aName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetElementsByName(const nsAString& aElementName,
|
||||
nsIDOMNodeList** aReturn)
|
||||
|
||||
@@ -163,13 +163,8 @@ public:
|
||||
nsIContent *GetBody(nsresult *aResult);
|
||||
already_AddRefed<nsContentList> GetElementsByName(const nsAString & aName)
|
||||
{
|
||||
nsString* elementNameData = new nsString(aName);
|
||||
|
||||
return NS_GetFuncStringContentList(this,
|
||||
MatchNameAttribute,
|
||||
nsContentUtils::DestroyMatchString,
|
||||
elementNameData,
|
||||
*elementNameData);
|
||||
return NS_GetFuncStringContentList(this, MatchNameAttribute, nsnull,
|
||||
UseExistingNameString, aName);
|
||||
}
|
||||
|
||||
// nsIDOMNSHTMLDocument interface
|
||||
@@ -259,6 +254,7 @@ protected:
|
||||
nsIAtom* aAtom, void* aData);
|
||||
static PRBool MatchNameAttribute(nsIContent* aContent, PRInt32 aNamespaceID,
|
||||
nsIAtom* aAtom, void* aData);
|
||||
static void* UseExistingNameString(nsINode* aRootNode, const nsString* aName);
|
||||
|
||||
static void DocumentWriteTerminationFunc(nsISupports *aRef);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user