Bug 1044658 - 1/6 - remove useless template parameters around WeakPtr - r=froydnj
authorBenoit Jacob <bjacob@mozilla.com>
Wed, 30 Jul 2014 15:52:01 -0400
changeset 196857 cd926197c6c91d7222e177a6e6e6c2950c862bb3
parent 196856 a415af888b4abcc0b0579c33acd49cc0b2ca273d
child 196858 a8f57c397a0449f565b61b3791a071304292b012
push id46988
push userbjacob@mozilla.com
push dateWed, 30 Jul 2014 19:52:29 +0000
treeherdermozilla-inbound@79d249340b3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1044658
milestone34.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 1044658 - 1/6 - remove useless template parameters around WeakPtr - r=froydnj
mfbt/WeakPtr.h
--- a/mfbt/WeakPtr.h
+++ b/mfbt/WeakPtr.h
@@ -72,18 +72,18 @@
 #include "mozilla/NullPtr.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/TypeTraits.h"
 
 #include <string.h>
 
 namespace mozilla {
 
-template <typename T, class WeakReference> class WeakPtrBase;
-template <typename T, class WeakReference> class SupportsWeakPtrBase;
+template <typename T> class WeakPtrBase;
+template <typename T> class SupportsWeakPtrBase;
 
 namespace detail {
 
 // This can live beyond the lifetime of the class derived from
 // SupportsWeakPtrBase.
 template<class T>
 class WeakReference : public ::mozilla::RefCounted<WeakReference<T> >
 {
@@ -113,89 +113,89 @@ public:
     return nameBuffer;
   }
 
   size_t typeSize() const { return sizeof(*this); }
 #undef snprintf
 #endif
 
 private:
-  friend class WeakPtrBase<T, WeakReference<T> >;
-  friend class SupportsWeakPtrBase<T, WeakReference<T> >;
+  friend class WeakPtrBase<T>;
+  friend class SupportsWeakPtrBase<T>;
 
   void detach() { mPtr = nullptr; }
 
   T* mPtr;
 };
 
 } // namespace detail
 
-template <typename T, class WeakReference>
+template <typename T>
 class SupportsWeakPtrBase
 {
 public:
-  WeakPtrBase<T, WeakReference> asWeakPtr()
+  WeakPtrBase<T> asWeakPtr()
   {
     if (!weakRef) {
-      weakRef = new WeakReference(static_cast<T*>(this));
+      weakRef = new detail::WeakReference<T>(static_cast<T*>(this));
     }
-    return WeakPtrBase<T, WeakReference>(weakRef);
+    return WeakPtrBase<T>(weakRef);
   }
 
 protected:
   ~SupportsWeakPtrBase()
   {
-    static_assert(IsBaseOf<SupportsWeakPtrBase<T, WeakReference>, T>::value,
-                  "T must derive from SupportsWeakPtrBase<T, WeakReference>");
+    static_assert(IsBaseOf<SupportsWeakPtrBase<T>, T>::value,
+                  "T must derive from SupportsWeakPtrBase<T>");
     if (weakRef) {
       weakRef->detach();
     }
   }
 
 private:
-  friend class WeakPtrBase<T, WeakReference>;
+  friend class WeakPtrBase<T>;
 
-  RefPtr<WeakReference> weakRef;
+  RefPtr<detail::WeakReference<T>> weakRef;
 };
 
 template <typename T>
-class SupportsWeakPtr : public SupportsWeakPtrBase<T, detail::WeakReference<T> >
+class SupportsWeakPtr : public SupportsWeakPtrBase<T>
 {
 };
 
-template <typename T, class WeakReference>
+template <typename T>
 class WeakPtrBase
 {
 public:
-  WeakPtrBase(const WeakPtrBase<T, WeakReference>& aOther)
+  WeakPtrBase(const WeakPtrBase<T>& aOther)
     : mRef(aOther.mRef)
   {}
 
   // Ensure that mRef is dereferenceable in the uninitialized state.
-  WeakPtrBase() : mRef(new WeakReference(nullptr)) {}
+  WeakPtrBase() : mRef(new detail::WeakReference<T>(nullptr)) {}
 
   operator T*() const { return mRef->get(); }
   T& operator*() const { return *mRef->get(); }
 
   T* operator->() const { return mRef->get(); }
 
   T* get() const { return mRef->get(); }
 
 private:
-  friend class SupportsWeakPtrBase<T, WeakReference>;
+  friend class SupportsWeakPtrBase<T>;
 
-  explicit WeakPtrBase(const RefPtr<WeakReference>& aOther) : mRef(aOther) {}
+  explicit WeakPtrBase(const RefPtr<detail::WeakReference<T>>& aOther) : mRef(aOther) {}
 
-  RefPtr<WeakReference> mRef;
+  RefPtr<detail::WeakReference<T>> mRef;
 };
 
 template <typename T>
-class WeakPtr : public WeakPtrBase<T, detail::WeakReference<T> >
+class WeakPtr : public WeakPtrBase<T>
 {
-  typedef WeakPtrBase<T, detail::WeakReference<T> > Base;
+  typedef WeakPtrBase<T> Base;
 public:
   WeakPtr(const WeakPtr<T>& aOther) : Base(aOther) {}
   MOZ_IMPLICIT WeakPtr(const Base& aOther) : Base(aOther) {}
   WeakPtr() {}
 };
 
 } // namespace mozilla