Bug 925495 part 2. Make the localName and nodeName bindings use DOMString, for extra speed. r=smaug

This commit is contained in:
Boris Zbarsky 2013-10-11 12:28:23 -04:00
parent 44bf9cd737
commit 9a8b30c350
2 changed files with 16 additions and 8 deletions

View File

@ -20,6 +20,7 @@
#include "mozilla/MemoryReporting.h"
#include "mozilla/dom/EventTarget.h" // for base class
#include "js/TypeDecls.h" // for Handle, Value, JSObject, JSContext
#include "mozilla/dom/DOMString.h"
// Including 'windows.h' will #define GetClassInfo to something else.
#ifdef XP_WIN
@ -1483,9 +1484,11 @@ public:
*/
uint32_t Length() const;
void GetNodeName(nsAString& aNodeName) const
void GetNodeName(mozilla::dom::DOMString& aNodeName)
{
aNodeName = NodeName();
const nsString& nodeName = NodeName();
aNodeName.SetStringBuffer(nsStringBuffer::FromString(nodeName),
nodeName.Length());
}
void GetBaseURI(nsAString& aBaseURI) const;
bool HasChildNodes() const
@ -1536,9 +1539,15 @@ public:
mNodeInfo->GetPrefix(aPrefix);
}
#endif
void GetLocalName(nsAString& aLocalName)
void GetLocalName(mozilla::dom::DOMString& aLocalName)
{
aLocalName = mNodeInfo->LocalName();
const nsString& localName = LocalName();
if (localName.IsVoid()) {
aLocalName.SetNull();
} else {
aLocalName.SetStringBuffer(nsStringBuffer::FromString(localName),
localName.Length());
}
}
// HasAttributes is defined inline in Element.h.
bool HasAttributes() const;
@ -1756,7 +1765,7 @@ ToCanonicalSupports(nsINode* aPointer)
#define NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER(...) \
NS_IMETHOD GetNodeName(nsAString& aNodeName) __VA_ARGS__ \
{ \
nsINode::GetNodeName(aNodeName); \
aNodeName = nsINode::NodeName(); \
return NS_OK; \
} \
NS_IMETHOD GetNodeValue(nsAString& aNodeValue) __VA_ARGS__ \
@ -1858,7 +1867,7 @@ ToCanonicalSupports(nsINode* aPointer)
} \
NS_IMETHOD GetLocalName(nsAString& aLocalName) __VA_ARGS__ \
{ \
nsINode::GetLocalName(aLocalName); \
aLocalName = nsINode::LocalName(); \
return NS_OK; \
} \
using nsINode::HasAttributes; \

View File

@ -62,8 +62,7 @@ NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
{
nsCOMPtr<nsIContent>nodeAsContent = do_QueryInterface(mNode);
nsCOMPtr<nsIContent>parentAsContent = do_QueryInterface(mParent);
nsString namestr;
mNode->GetNodeName(namestr);
nsString namestr = mNode->NodeName();
char* nodename = ToNewCString(namestr);
printf("%p Do Insert Element of %p <%s> into parent %p at offset %d\n",
static_cast<void*>(this),