Bug 1290036 - Make CreateDecoderParams get rid of unnecessary copy/move. r=gerald
authorJames Cheng <jacheng@mozilla.com>
Thu, 28 Jul 2016 17:52:49 +0800
changeset 349369 a9d6defe44163d7375df62109877519dc658f845
parent 349368 85b1e566b5b8c665604bd6a866f916ed2f532948
child 349370 b3cd11b98793db8a9222f76b849068b96c66392d
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1290036
milestone50.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 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