Bug 1422524: Inline nsAttrValue::Type. r=xidorn
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 02 Dec 2017 20:43:12 +0100
changeset 449030 f5921af9f1a6a35adfe68977c6437f91fc866d18
parent 449029 f77500d7262c5cc07bbe7a17a4e365d547b4be4d
child 449031 97d4dda25d6514168b314658a6b341469203ab4c
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1422524
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1422524: Inline nsAttrValue::Type. r=xidorn MozReview-Commit-ID: I2uTeremrsS
dom/base/Element.h
dom/base/nsAttrValue.cpp
dom/base/nsAttrValue.h
dom/base/nsAttrValueInlines.h
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -28,16 +28,17 @@
 #include "nsPresContext.h"
 #include "mozilla/CORSMode.h"
 #include "mozilla/Attributes.h"
 #include "nsIScrollableFrame.h"
 #include "mozilla/dom/Attr.h"
 #include "nsISMILAttr.h"
 #include "mozilla/dom/DOMRect.h"
 #include "nsAttrValue.h"
+#include "nsAttrValueInlines.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/DOMTokenListSupportedTokens.h"
 #include "mozilla/dom/WindowBinding.h"
 #include "mozilla/dom/ElementBinding.h"
 #include "mozilla/dom/Nullable.h"
 #include "mozilla/dom/PointerEventHandler.h"
 #include "mozilla/UniquePtr.h"
--- a/dom/base/nsAttrValue.cpp
+++ b/dom/base/nsAttrValue.cpp
@@ -181,35 +181,16 @@ nsAttrValue::Init()
 /* static */
 void
 nsAttrValue::Shutdown()
 {
   delete sEnumTableArray;
   sEnumTableArray = nullptr;
 }
 
-nsAttrValue::ValueType
-nsAttrValue::Type() const
-{
-  switch (BaseType()) {
-    case eIntegerBase:
-    {
-      return static_cast<ValueType>(mBits & NS_ATTRVALUE_INTEGERTYPE_MASK);
-    }
-    case eOtherBase:
-    {
-      return GetMiscContainer()->mType;
-    }
-    default:
-    {
-      return static_cast<ValueType>(static_cast<uint16_t>(BaseType()));
-    }
-  }
-}
-
 void
 nsAttrValue::Reset()
 {
   switch(BaseType()) {
     case eStringBase:
     {
       nsStringBuffer* str = static_cast<nsStringBuffer*>(GetPtr());
       if (str) {
--- a/dom/base/nsAttrValue.h
+++ b/dom/base/nsAttrValue.h
@@ -127,17 +127,17 @@ public:
   explicit nsAttrValue(const nsIntMargin& aValue);
   ~nsAttrValue();
 
   inline const nsAttrValue& operator=(const nsAttrValue& aOther);
 
   static nsresult Init();
   static void Shutdown();
 
-  ValueType Type() const;
+  inline ValueType Type() const;
   // Returns true when this value is self-contained and does not depend on
   // the state of its associated element.
   // Returns false when this value depends on the state of its associated
   // element and may be invalid if that state has been changed by changes to
   // that element state outside of attribute setting.
   inline bool StoresOwnData() const;
 
   void Reset();
@@ -499,23 +499,16 @@ private:
 
 inline const nsAttrValue&
 nsAttrValue::operator=(const nsAttrValue& aOther)
 {
   SetTo(aOther);
   return *this;
 }
 
-inline nsAtom*
-nsAttrValue::GetAtomValue() const
-{
-  NS_PRECONDITION(Type() == eAtom, "wrong type");
-  return reinterpret_cast<nsAtom*>(GetPtr());
-}
-
 inline nsAttrValue::ValueBaseType
 nsAttrValue::BaseType() const
 {
   return static_cast<ValueBaseType>(mBits & NS_ATTRVALUE_BASETYPE_MASK);
 }
 
 inline void*
 nsAttrValue::GetPtr() const
@@ -526,35 +519,9 @@ nsAttrValue::GetPtr() const
 }
 
 inline bool
 nsAttrValue::IsEmptyString() const
 {
   return !mBits;
 }
 
-inline void
-nsAttrValue::ToString(mozilla::dom::DOMString& aResult) const
-{
-  switch (Type()) {
-    case eString:
-    {
-      nsStringBuffer* str = static_cast<nsStringBuffer*>(GetPtr());
-      if (str) {
-        aResult.SetStringBuffer(str, str->StorageSize()/sizeof(char16_t) - 1);
-      }
-      // else aResult is already empty
-      return;
-    }
-    case eAtom:
-    {
-      nsAtom *atom = static_cast<nsAtom*>(GetPtr());
-      aResult.SetOwnedAtom(atom, mozilla::dom::DOMString::eNullNotExpected);
-      break;
-    }
-    default:
-    {
-      ToString(aResult.AsAString());
-    }
-  }
-}
-
 #endif
--- a/dom/base/nsAttrValueInlines.h
+++ b/dom/base/nsAttrValueInlines.h
@@ -231,9 +231,61 @@ nsAttrValue::GetIntInternal() const
                "getting integer from non-integer");
   // Make sure we get a signed value.
   // Lets hope the optimizer optimizes this into a shift. Unfortunatly signed
   // bitshift right is implementaion dependant.
   return static_cast<int32_t>(mBits & ~NS_ATTRVALUE_INTEGERTYPE_MASK) /
          NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER;
 }
 
+inline nsAttrValue::ValueType
+nsAttrValue::Type() const
+{
+  switch (BaseType()) {
+    case eIntegerBase:
+    {
+      return static_cast<ValueType>(mBits & NS_ATTRVALUE_INTEGERTYPE_MASK);
+    }
+    case eOtherBase:
+    {
+      return GetMiscContainer()->mType;
+    }
+    default:
+    {
+      return static_cast<ValueType>(static_cast<uint16_t>(BaseType()));
+    }
+  }
+}
+
+inline nsAtom*
+nsAttrValue::GetAtomValue() const
+{
+  NS_PRECONDITION(Type() == eAtom, "wrong type");
+  return reinterpret_cast<nsAtom*>(GetPtr());
+}
+
+inline void
+nsAttrValue::ToString(mozilla::dom::DOMString& aResult) const
+{
+  switch (Type()) {
+    case eString:
+    {
+      nsStringBuffer* str = static_cast<nsStringBuffer*>(GetPtr());
+      if (str) {
+        aResult.SetStringBuffer(str, str->StorageSize()/sizeof(char16_t) - 1);
+      }
+      // else aResult is already empty
+      return;
+    }
+    case eAtom:
+    {
+      nsAtom *atom = static_cast<nsAtom*>(GetPtr());
+      aResult.SetOwnedAtom(atom, mozilla::dom::DOMString::eNullNotExpected);
+      break;
+    }
+    default:
+    {
+      ToString(aResult.AsAString());
+    }
+  }
+}
+
 #endif