Bug 1179787 - part 1 - forward StorensRefPtrPassByPtr's constructor argument; r=botond
authorNathan Froyd <froydnj@mozilla.com>
Thu, 02 Jul 2015 11:05:52 -0400
changeset 281576 a8f6ded61005b3d2028a8cddc21f4588f4d948a1
parent 281575 69871c00379ba9a262f3a8cc2072da4a0892b2ee
child 281577 63ad8e412a0f3fb679ddec0183c1ee0bb981b748
push id3894
push usermconley@mozilla.com
push dateThu, 30 Jul 2015 00:27:47 +0000
reviewersbotond
bugs1179787
milestone42.0a1
Bug 1179787 - part 1 - forward StorensRefPtrPassByPtr's constructor argument; r=botond StorensRefPtrPassByPtr is currently used for storing reference-counted types passed as T* template arguments to NS_NewRunnableMethodWith*. We'd also like to use it to store nsRefPtr<T> template arguments. While it could be used in its current form, it'd be better for its constructor to support forwarding, so that something like: NS_NewRunnableMethodWithArg<nsRefPtr<T>>(..., nsRefPtr<T>(local)); doesn't cause unnecessary reference counting.
xpcom/glue/nsThreadUtils.h
--- a/xpcom/glue/nsThreadUtils.h
+++ b/xpcom/glue/nsThreadUtils.h
@@ -446,17 +446,17 @@ struct IsParameterStorageClass<StoreCons
 
 template<typename T>
 struct StorensRefPtrPassByPtr
 {
   typedef nsRefPtr<T> stored_type;
   typedef T* passed_type;
   stored_type m;
   template <typename A>
-  explicit StorensRefPtrPassByPtr(A a) : m(a) {}
+  explicit StorensRefPtrPassByPtr(A&& a) : m(mozilla::Forward<A>(a)) {}
   passed_type PassAsParameter() { return m.get(); }
 };
 template<typename S>
 struct IsParameterStorageClass<StorensRefPtrPassByPtr<S>>
   : public mozilla::TrueType {};
 
 template<typename T>
 struct StorePtrPassByPtr