Bug 903543 - eliminate static constructors for SMIL type singletons; r=dholbert
authorNathan Froyd <froydnj@mozilla.com>
Mon, 12 Aug 2013 10:13:34 -0400
changeset 142682 8ea63efc27c2726b0cf54c77dbc66963ea71dcde
parent 142681 f67ef09058e28e5a16bb21501beec0f43dc70042
child 142683 9cf0ecb708f50a1f89678adb889687a9d194ecf6
push id25104
push useremorley@mozilla.com
push dateThu, 15 Aug 2013 10:56:09 +0000
treeherdermozilla-central@31c08ca022b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs903543
milestone26.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 903543 - eliminate static constructors for SMIL type singletons; r=dholbert Add MOZ_CONSTEXPR to the constructors to inform the compiler the constructors can be folded away. Remove protected/private destructors so that static destructors don't have to be registered with static constructors.
content/smil/SMILBoolType.h
content/smil/SMILEnumType.h
content/smil/SMILIntegerType.h
content/smil/SMILStringType.h
content/smil/nsISMILType.h
content/smil/nsSMILCSSValueType.h
content/smil/nsSMILFloatType.h
content/smil/nsSMILNullType.h
content/svg/content/src/SVGIntegerPairSMILType.h
content/svg/content/src/SVGLengthListSMILType.h
content/svg/content/src/SVGMotionSMILType.h
content/svg/content/src/SVGNumberListSMILType.h
content/svg/content/src/SVGNumberPairSMILType.h
content/svg/content/src/SVGOrientSMILType.h
content/svg/content/src/SVGPathSegListSMILType.h
content/svg/content/src/SVGPointListSMILType.h
content/svg/content/src/SVGTransformListSMILType.h
content/svg/content/src/SVGViewBoxSMILType.h
--- a/content/smil/SMILBoolType.h
+++ b/content/smil/SMILBoolType.h
@@ -35,17 +35,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SMILBoolType()  {}
-  ~SMILBoolType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SMILBoolType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SMILBOOLTYPE_H_
--- a/content/smil/SMILEnumType.h
+++ b/content/smil/SMILEnumType.h
@@ -36,17 +36,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SMILEnumType()  {}
-  ~SMILEnumType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SMILEnumType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SMILENUMTYPE_H_
--- a/content/smil/SMILIntegerType.h
+++ b/content/smil/SMILIntegerType.h
@@ -32,14 +32,14 @@ public:
   static SMILIntegerType*
   Singleton()
   {
     static SMILIntegerType sSingleton;
     return &sSingleton;
   }
 
 private:
-  SMILIntegerType() {}
+  MOZ_CONSTEXPR SMILIntegerType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SMILINTEGERTYPE_H_
--- a/content/smil/SMILStringType.h
+++ b/content/smil/SMILStringType.h
@@ -36,17 +36,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SMILStringType()  {}
-  ~SMILStringType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SMILStringType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SMILSTRINGTYPE_H_
--- a/content/smil/nsISMILType.h
+++ b/content/smil/nsISMILType.h
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #ifndef NS_ISMILTYPE_H_
 #define NS_ISMILTYPE_H_
 
+#include "mozilla/Attributes.h"
 #include "nscore.h"
 
 class nsSMILValue;
 
 //////////////////////////////////////////////////////////////////////////////
 // nsISMILType: Interface for defining the basic operations needed for animating
 // a particular kind of data (e.g. lengths, colors, transformation matrices).
 //
@@ -202,18 +203,11 @@ protected:
    *          available for storing the result.
    *
    * @pre aStartVal.mType == aEndVal.mType == aResult.mType == this
    */
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const = 0;
-
-  /**
-   * Protected destructor, to ensure that no one accidentally deletes an
-   * instance of this class.
-   * (The only instances in existence should be singletons - one per subclass.)
-   */
-  ~nsISMILType() {}
 };
 
 #endif // NS_ISMILTYPE_H_
--- a/content/smil/nsSMILCSSValueType.h
+++ b/content/smil/nsSMILCSSValueType.h
@@ -93,15 +93,13 @@ public:
    *
    * @param       aValue   The nsSMILValue to be converted into a string.
    * @param [out] aString  The string to be populated with the given value.
    * @return               true on success, false on failure.
    */
   static bool ValueToString(const nsSMILValue& aValue, nsAString& aString);
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  nsSMILCSSValueType()  {}
-  ~nsSMILCSSValueType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR nsSMILCSSValueType() {}
 };
 
 #endif // NS_SMILCSSVALUETYPE_H_
--- a/content/smil/nsSMILFloatType.h
+++ b/content/smil/nsSMILFloatType.h
@@ -34,15 +34,13 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  nsSMILFloatType()  {}
-  ~nsSMILFloatType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR nsSMILFloatType() {}
 };
 
 #endif // NS_SMILFLOATTYPE_H_
--- a/content/smil/nsSMILNullType.h
+++ b/content/smil/nsSMILNullType.h
@@ -37,15 +37,13 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  nsSMILNullType()  {}
-  ~nsSMILNullType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR nsSMILNullType() {}
 };
 
 #endif // NS_SMILNULLTYPE_H_
--- a/content/svg/content/src/SVGIntegerPairSMILType.h
+++ b/content/svg/content/src/SVGIntegerPairSMILType.h
@@ -38,17 +38,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SVGIntegerPairSMILType()  {}
-  ~SVGIntegerPairSMILType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SVGIntegerPairSMILType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGINTEGERPAIRSMILTYPE_H_
--- a/content/svg/content/src/SVGLengthListSMILType.h
+++ b/content/svg/content/src/SVGLengthListSMILType.h
@@ -86,17 +86,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SVGLengthListSMILType() {}
-  ~SVGLengthListSMILType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SVGLengthListSMILType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGLENGTHLISTSMILTYPE_H_
--- a/content/svg/content/src/SVGMotionSMILType.h
+++ b/content/svg/content/src/SVGMotionSMILType.h
@@ -66,17 +66,15 @@ public:
   // Used to generate a nsSMILValue for the point at the given distance along
   // the given path.
   static nsSMILValue ConstructSMILValue(gfxFlattenedPath* aPath,
                                         float aDist,
                                         RotateType aRotateType,
                                         float aRotateAngle);
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SVGMotionSMILType()  {}
-  ~SVGMotionSMILType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SVGMotionSMILType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGMOTIONSMILTYPE_H_
--- a/content/svg/content/src/SVGNumberListSMILType.h
+++ b/content/svg/content/src/SVGNumberListSMILType.h
@@ -40,17 +40,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SVGNumberListSMILType() {}
-  ~SVGNumberListSMILType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SVGNumberListSMILType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGNUMBERLISTSMILTYPE_H_
--- a/content/svg/content/src/SVGNumberPairSMILType.h
+++ b/content/svg/content/src/SVGNumberPairSMILType.h
@@ -33,17 +33,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SVGNumberPairSMILType()  {}
-  ~SVGNumberPairSMILType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SVGNumberPairSMILType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGNUMBERPAIRSMILTYPE_H_
--- a/content/svg/content/src/SVGOrientSMILType.h
+++ b/content/svg/content/src/SVGOrientSMILType.h
@@ -53,17 +53,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SVGOrientSMILType()  {}
-  ~SVGOrientSMILType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SVGOrientSMILType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGORIENTSMILTYPE_H_
--- a/content/svg/content/src/SVGPathSegListSMILType.h
+++ b/content/svg/content/src/SVGPathSegListSMILType.h
@@ -44,17 +44,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SVGPathSegListSMILType() {}
-  ~SVGPathSegListSMILType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SVGPathSegListSMILType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGPATHSEGLISTSMILTYPE_H_
--- a/content/svg/content/src/SVGPointListSMILType.h
+++ b/content/svg/content/src/SVGPointListSMILType.h
@@ -40,17 +40,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SVGPointListSMILType() {}
-  ~SVGPointListSMILType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SVGPointListSMILType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGPOINTLISTSMILTYPE_H_
--- a/content/svg/content/src/SVGTransformListSMILType.h
+++ b/content/svg/content/src/SVGTransformListSMILType.h
@@ -116,17 +116,15 @@ public:
                                   nsSMILValue& aValue);
   static bool AppendTransforms(const SVGTransformList& aList,
                                  nsSMILValue& aValue);
   static bool GetTransforms(const nsSMILValue& aValue,
                               FallibleTArray<nsSVGTransform>& aTransforms);
 
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SVGTransformListSMILType() {}
-  ~SVGTransformListSMILType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SVGTransformListSMILType() {}
 };
 
 } // end namespace mozilla
 
 #endif // SVGLISTTRANSFORMSMILTYPE_H_
--- a/content/svg/content/src/SVGViewBoxSMILType.h
+++ b/content/svg/content/src/SVGViewBoxSMILType.h
@@ -33,17 +33,15 @@ protected:
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
 private:
-  // Private constructor & destructor: prevent instances beyond my singleton,
-  // and prevent others from deleting my singleton.
-  SVGViewBoxSMILType()  {}
-  ~SVGViewBoxSMILType() {}
+  // Private constructor: prevent instances beyond my singleton.
+  MOZ_CONSTEXPR SVGViewBoxSMILType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGVIEWBOXSMILTYPE_H_