Bug 925495 part 2. Make the localName and nodeName bindings use DOMString, for extra speed. r=smaug
☠☠ backed out by fdb83f77bdb3 ☠ ☠
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 11 Oct 2013 12:28:23 -0400
changeset 150525 46029c9fbfe4c0f6cdea54ed3763c5cefa67dca8
parent 150524 6114164c3d1b8110074aa66de78660e9c0a4a5ee
child 150526 877a227c502f07a77a1600edf3285665218ae0fb
push id3006
push userkwierso@gmail.com
push dateSat, 12 Oct 2013 02:00:44 +0000
treeherderfx-team@3ff6c5ec4dc5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs925495
milestone27.0a1
Bug 925495 part 2. Make the localName and nodeName bindings use DOMString, for extra speed. r=smaug
content/base/public/nsINode.h
editor/libeditor/base/InsertElementTxn.cpp
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -15,16 +15,17 @@
 #include "nsNodeInfoManager.h"      // for use in NodePrincipal()
 #include "nsPropertyTable.h"        // for typedefs
 #include "nsTObserverArray.h"       // for member
 #include "nsWindowMemoryReporter.h" // for NS_DECL_SIZEOF_EXCLUDING_THIS
 #include "mozilla/ErrorResult.h"
 #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
 #ifdef GetClassInfo
 #undef GetClassInfo
 #endif
 #endif
 
@@ -1478,19 +1479,21 @@ public:
   void GetBoundMutationObservers(nsTArray<nsRefPtr<nsDOMMutationObserver> >& aResult);
 
   /**
    * Returns the length of this node, as specified at
    * <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-length>
    */
   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
   {
     return HasChildren();
   }
   uint16_t CompareDocumentPosition(nsINode& aOther) const;
   void GetNodeValue(nsAString& aNodeValue)
@@ -1531,19 +1534,21 @@ public:
     mNodeInfo->GetNamespaceURI(aNamespaceURI);
   }
 #ifdef MOZILLA_INTERNAL_API
   void GetPrefix(nsAString& aPrefix)
   {
     mNodeInfo->GetPrefix(aPrefix);
   }
 #endif
-  void GetLocalName(nsAString& aLocalName)
+  void GetLocalName(mozilla::dom::DOMString& aLocalName)
   {
-    aLocalName = mNodeInfo->LocalName();
+    const nsString& localName = LocalName();
+    aLocalName.SetStringBuffer(nsStringBuffer::FromString(localName),
+                               localName.Length());
   }
   // HasAttributes is defined inline in Element.h.
   bool HasAttributes() const;
   nsDOMAttributeMap* GetAttributes();
   JS::Value SetUserData(JSContext* aCx, const nsAString& aKey,
                         JS::Handle<JS::Value> aData,
                         nsIDOMUserDataHandler* aHandler,
                         mozilla::ErrorResult& aError);
@@ -1751,17 +1756,17 @@ inline nsISupports*
 ToCanonicalSupports(nsINode* aPointer)
 {
   return 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__ \
   { \
     nsINode::GetNodeValue(aNodeValue); \
     return NS_OK; \
   } \
   NS_IMETHOD SetNodeValue(const nsAString& aNodeValue) __VA_ARGS__ \
@@ -1853,17 +1858,17 @@ ToCanonicalSupports(nsINode* aPointer)
   } \
   NS_IMETHOD GetPrefix(nsAString& aPrefix) __VA_ARGS__ \
   { \
     nsINode::GetPrefix(aPrefix); \
     return NS_OK; \
   } \
   NS_IMETHOD GetLocalName(nsAString& aLocalName) __VA_ARGS__ \
   { \
-    nsINode::GetLocalName(aLocalName); \
+    aLocalName = nsINode::LocalName(); \
     return NS_OK; \
   } \
   using nsINode::HasAttributes; \
   NS_IMETHOD HasAttributes(bool* aResult) __VA_ARGS__ \
   { \
     *aResult = nsINode::HasAttributes(); \
     return NS_OK; \
   } \
--- a/editor/libeditor/base/InsertElementTxn.cpp
+++ b/editor/libeditor/base/InsertElementTxn.cpp
@@ -57,18 +57,17 @@ NS_IMETHODIMP InsertElementTxn::Init(nsI
 
 NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
 {
 #ifdef DEBUG
   if (gNoisy) 
   { 
     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),
            static_cast<void*>(nodeAsContent.get()),
            nodename,
            static_cast<void*>(parentAsContent.get()),
            mOffset); 
     nsMemory::Free(nodename);