Bug 1406440 - don't inline nsSMILNullType::Singleton(); r=dholbert
authorNathan Froyd <froydnj@mozilla.com>
Mon, 09 Oct 2017 10:39:38 -0400
changeset 676888 7fd54747a3b754fd1dfad0be8fd561d78fa23b67
parent 676887 b668425e2914ffbecaa216dc0833bab3ba0ddd58
child 676889 250d1b8ce9c3afdab127e1527de7f48810950623
push id83658
push userbmo:tchiovoloni@mozilla.com
push dateMon, 09 Oct 2017 20:19:32 +0000
reviewersdholbert
bugs1406440
milestone58.0a1
Bug 1406440 - don't inline nsSMILNullType::Singleton(); r=dholbert Defining Singleton() in the declaration of nsSMILNullType implicitly sticks an "inline" on the function, which is not what we want: inlining it spreads around a lot of static initialization code. Providing an out-of-line definition is much better in terms of code size.
dom/smil/nsSMILNullType.cpp
dom/smil/nsSMILNullType.h
--- a/dom/smil/nsSMILNullType.cpp
+++ b/dom/smil/nsSMILNullType.cpp
@@ -3,16 +3,23 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsSMILNullType.h"
 #include "nsSMILValue.h"
 #include "nsDebug.h"
 
+/*static*/ nsSMILNullType*
+nsSMILNullType::Singleton()
+{
+  static nsSMILNullType sSingleton;
+  return &sSingleton;
+}
+
 nsresult
 nsSMILNullType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aSrc.mType == this, "Unexpected source type");
   aDest.mU    = aSrc.mU;
   aDest.mType = Singleton();
   return NS_OK;
--- a/dom/smil/nsSMILNullType.h
+++ b/dom/smil/nsSMILNullType.h
@@ -9,22 +9,17 @@
 
 #include "mozilla/Attributes.h"
 #include "nsISMILType.h"
 
 class nsSMILNullType : public nsISMILType
 {
 public:
   // Singleton for nsSMILValue objects to hold onto.
-  static nsSMILNullType*
-  Singleton()
-  {
-    static nsSMILNullType sSingleton;
-    return &sSingleton;
-  }
+  static nsSMILNullType* Singleton();
 
 protected:
   // nsISMILType Methods
   // -------------------
   virtual void Init(nsSMILValue& aValue) const override {}
   virtual void Destroy(nsSMILValue& aValue) const override {}
   virtual nsresult Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const override;