Bug 903543 - eliminate static constructors from SMIL types (and destructors, in opt builds); r=dholbert
☠☠ backed out by b5c2851c903c ☠ ☠
authorNathan Froyd <froydnj@mozilla.com>
Fri, 09 Aug 2013 14:08:31 -0400
changeset 142148 00fc7e525678938cd4787513bfa7ecda51c8e59f
parent 142147 afbed604db0495f4a936cf835eda8c13e103ba9f
child 142149 75fb08918611aaff7044d31ae46edab86219906e
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdholbert
bugs903543
milestone26.0a1
Bug 903543 - eliminate static constructors from SMIL types (and destructors, in opt builds); r=dholbert
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
@@ -37,15 +37,17 @@ protected:
   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()  {}
+  MOZ_CONSTEXPR SMILBoolType() {}
+#ifdef DEBUG
   ~SMILBoolType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SMILBOOLTYPE_H_
--- a/content/smil/SMILEnumType.h
+++ b/content/smil/SMILEnumType.h
@@ -38,15 +38,17 @@ protected:
   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()  {}
+  MOZ_CONSTEXPR SMILEnumType() {}
+#ifdef DEBUG
   ~SMILEnumType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SMILENUMTYPE_H_
--- a/content/smil/SMILIntegerType.h
+++ b/content/smil/SMILIntegerType.h
@@ -32,14 +32,17 @@ public:
   static SMILIntegerType*
   Singleton()
   {
     static SMILIntegerType sSingleton;
     return &sSingleton;
   }
 
 private:
-  SMILIntegerType() {}
+  MOZ_CONSTEXPR SMILIntegerType() {}
+#ifdef DEBUG
+  ~SMILIntegerType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SMILINTEGERTYPE_H_
--- a/content/smil/SMILStringType.h
+++ b/content/smil/SMILStringType.h
@@ -38,15 +38,17 @@ protected:
   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()  {}
+  MOZ_CONSTEXPR SMILStringType() {}
+#ifdef DEBUG
   ~SMILStringType() {}
+#endif
 };
 
 } // 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).
 //
@@ -207,13 +208,22 @@ protected:
                                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.)
+   *
+   * This destructor and the destructors of subclasses are only defined in
+   * debug builds.  For non-debug builds, we let the compiler define the
+   * default (public) constructor.  The compiler understands that the default
+   * destructor doesn't necessarily need to be invoked (e.g. if there are no
+   * members to destroy) and so will avoid creating static destructors (and
+   * registering them with static *constructors*) in non-debug builds.
    */
+#ifdef DEBUG
   ~nsISMILType() {}
+#endif
 };
 
 #endif // NS_ISMILTYPE_H_
--- a/content/smil/nsSMILCSSValueType.h
+++ b/content/smil/nsSMILCSSValueType.h
@@ -95,13 +95,15 @@ public:
    * @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()  {}
+  MOZ_CONSTEXPR nsSMILCSSValueType() {}
+#ifdef DEBUG
   ~nsSMILCSSValueType() {}
+#endif
 };
 
 #endif // NS_SMILCSSVALUETYPE_H_
--- a/content/smil/nsSMILFloatType.h
+++ b/content/smil/nsSMILFloatType.h
@@ -36,13 +36,15 @@ protected:
   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()  {}
+  MOZ_CONSTEXPR nsSMILFloatType() {}
+#ifdef DEBUG
   ~nsSMILFloatType() {}
+#endif
 };
 
 #endif // NS_SMILFLOATTYPE_H_
--- a/content/smil/nsSMILNullType.h
+++ b/content/smil/nsSMILNullType.h
@@ -39,13 +39,15 @@ protected:
   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()  {}
+  MOZ_CONSTEXPR nsSMILNullType() {}
+#ifdef DEBUG
   ~nsSMILNullType() {}
+#endif
 };
 
 #endif // NS_SMILNULLTYPE_H_
--- a/content/svg/content/src/SVGIntegerPairSMILType.h
+++ b/content/svg/content/src/SVGIntegerPairSMILType.h
@@ -40,15 +40,17 @@ protected:
   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()  {}
+  MOZ_CONSTEXPR SVGIntegerPairSMILType() {}
+#ifdef DEBUG
   ~SVGIntegerPairSMILType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGINTEGERPAIRSMILTYPE_H_
--- a/content/svg/content/src/SVGLengthListSMILType.h
+++ b/content/svg/content/src/SVGLengthListSMILType.h
@@ -88,15 +88,17 @@ protected:
   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() {}
+  MOZ_CONSTEXPR SVGLengthListSMILType() {}
+#ifdef DEBUG
   ~SVGLengthListSMILType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGLENGTHLISTSMILTYPE_H_
--- a/content/svg/content/src/SVGMotionSMILType.h
+++ b/content/svg/content/src/SVGMotionSMILType.h
@@ -68,15 +68,17 @@ public:
   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()  {}
+  MOZ_CONSTEXPR SVGMotionSMILType() {}
+#ifdef DEBUG
   ~SVGMotionSMILType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGMOTIONSMILTYPE_H_
--- a/content/svg/content/src/SVGNumberListSMILType.h
+++ b/content/svg/content/src/SVGNumberListSMILType.h
@@ -42,15 +42,17 @@ protected:
   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() {}
+  MOZ_CONSTEXPR SVGNumberListSMILType() {}
+#ifdef DEBUG
   ~SVGNumberListSMILType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGNUMBERLISTSMILTYPE_H_
--- a/content/svg/content/src/SVGNumberPairSMILType.h
+++ b/content/svg/content/src/SVGNumberPairSMILType.h
@@ -35,15 +35,17 @@ protected:
   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()  {}
+  MOZ_CONSTEXPR SVGNumberPairSMILType() {}
+#ifdef DEBUG
   ~SVGNumberPairSMILType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGNUMBERPAIRSMILTYPE_H_
--- a/content/svg/content/src/SVGOrientSMILType.h
+++ b/content/svg/content/src/SVGOrientSMILType.h
@@ -55,15 +55,17 @@ protected:
   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()  {}
+  MOZ_CONSTEXPR SVGOrientSMILType() {}
+#ifdef DEBUG
   ~SVGOrientSMILType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGORIENTSMILTYPE_H_
--- a/content/svg/content/src/SVGPathSegListSMILType.h
+++ b/content/svg/content/src/SVGPathSegListSMILType.h
@@ -46,15 +46,17 @@ protected:
   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() {}
+  MOZ_CONSTEXPR SVGPathSegListSMILType() {}
+#ifdef DEBUG
   ~SVGPathSegListSMILType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGPATHSEGLISTSMILTYPE_H_
--- a/content/svg/content/src/SVGPointListSMILType.h
+++ b/content/svg/content/src/SVGPointListSMILType.h
@@ -42,15 +42,17 @@ protected:
   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() {}
+  MOZ_CONSTEXPR SVGPointListSMILType() {}
+#ifdef DEBUG
   ~SVGPointListSMILType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGPOINTLISTSMILTYPE_H_
--- a/content/svg/content/src/SVGTransformListSMILType.h
+++ b/content/svg/content/src/SVGTransformListSMILType.h
@@ -118,15 +118,17 @@ public:
                                  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() {}
+  MOZ_CONSTEXPR SVGTransformListSMILType() {}
+#ifdef DEBUG
   ~SVGTransformListSMILType() {}
+#endif
 };
 
 } // end namespace mozilla
 
 #endif // SVGLISTTRANSFORMSMILTYPE_H_
--- a/content/svg/content/src/SVGViewBoxSMILType.h
+++ b/content/svg/content/src/SVGViewBoxSMILType.h
@@ -35,15 +35,17 @@ protected:
   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()  {}
+  MOZ_CONSTEXPR SVGViewBoxSMILType() {}
+#ifdef DEBUG
   ~SVGViewBoxSMILType() {}
+#endif
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGVIEWBOXSMILTYPE_H_