Bug 1290036 - Make CreateDecoderParams get rid of unnecessary copy/move. r?gerald draft
authorJames Cheng <jacheng@mozilla.com>
Thu, 28 Jul 2016 17:52:49 +0800
changeset 394182 2aff48e627cebc741f55bf4bd9da4d4a42471587
parent 393484 db3ed1fdbbeaf5ab1e8fe454780146e7499be3db
child 526757 4428c5d27dcbb2263e3156fbb0da85a5016a978a
push id24515
push userbmo:jacheng@mozilla.com
push dateFri, 29 Jul 2016 07:19:51 +0000
reviewersgerald
bugs1290036
milestone50.0a1
Bug 1290036 - Make CreateDecoderParams get rid of unnecessary copy/move. r?gerald MozReview-Commit-ID: HYUHoV4Vmkd
dom/media/platforms/PlatformDecoderModule.h
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -34,20 +34,20 @@ class CDMProxy;
 static LazyLogModule sPDMLog("PlatformDecoderModule");
 
 struct CreateDecoderParams {
   explicit CreateDecoderParams(const TrackInfo& aConfig)
     : mConfig(aConfig)
   {}
 
   template <typename T1, typename... Ts>
-  CreateDecoderParams(const TrackInfo& aConfig, T1 a1, Ts... as)
+  CreateDecoderParams(const TrackInfo& aConfig, T1&& a1, Ts&&... args)
     : mConfig(aConfig)
   {
-    Set(a1, as...);
+    Set(mozilla::Forward<T1>(a1), mozilla::Forward<Ts>(args)...);
   }
 
   const VideoInfo& VideoConfig() const
   {
     MOZ_ASSERT(mConfig.IsVideo());
     return *mConfig.GetAsVideoInfo();
   }
 
@@ -68,23 +68,20 @@ struct CreateDecoderParams {
 private:
   void Set(TaskQueue* aTaskQueue) { mTaskQueue = aTaskQueue; }
   void Set(MediaDataDecoderCallback* aCallback) { mCallback = aCallback; }
   void Set(DecoderDoctorDiagnostics* aDiagnostics) { mDiagnostics = aDiagnostics; }
   void Set(layers::ImageContainer* aImageContainer) { mImageContainer = aImageContainer; }
   void Set(layers::LayersBackend aLayersBackend) { mLayersBackend = aLayersBackend; }
   void Set(GMPCrashHelper* aCrashHelper) { mCrashHelper = aCrashHelper; }
   template <typename T1, typename T2, typename... Ts>
-  void Set(T1 a1, T2 a2, Ts... as)
+  void Set(T1&& a1, T2&& a2, Ts&&... args)
   {
-    // Parameter pack expansion trick, to call Set() on each argument.
-    using expander = int[];
-    (void)expander {
-      (Set(a1), 0), (Set(a2), 0), (Set(as), 0)...
-    };
+    Set(mozilla::Forward<T1>(a1));
+    Set(mozilla::Forward<T2>(a2), mozilla::Forward<Ts>(args)...);
   }
 };
 
 // The PlatformDecoderModule interface is used by the MediaFormatReader to
 // abstract access to decoders provided by various
 // platforms.
 // Each platform (Windows, MacOSX, Linux, B2G etc) must implement a
 // PlatformDecoderModule to provide access to its decoders in order to get