Bug 1290036 - Make CreateDecoderParams get rid of unnecessary copy/move. r?gerald
MozReview-Commit-ID: HYUHoV4Vmkd
--- 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