From 87eed890a42b40e3cb37696ffdb438564793bfdb Mon Sep 17 00:00:00 2001 From: Gerald Squelart Date: Wed, 5 Sep 2018 11:41:07 +0000 Subject: [PATCH] Bug 1488701 - Remove misleading std::move's - r=froydnj Doing std::move when returning/assigning a local or temporary object is preventing the compiler from performing copy elision. In the case of UniquePtr, it's easier to `return MakeUnique(...)` instead of the move verbose `UniquePtr r(new T(...)); return r;` Differential Revision: https://phabricator.services.mozilla.com/D5019 --HG-- extra : moz-landing-system : lando --- gfx/gl/SharedSurfaceANGLE.cpp | 11 ++++------- gfx/gl/SharedSurfaceD3D11Interop.cpp | 12 +++++------- ipc/mscom/PassthruProxy.cpp | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/gfx/gl/SharedSurfaceANGLE.cpp b/gfx/gl/SharedSurfaceANGLE.cpp index 42d4cc9580b7..8ffb30f455d8 100644 --- a/gfx/gl/SharedSurfaceANGLE.cpp +++ b/gfx/gl/SharedSurfaceANGLE.cpp @@ -86,10 +86,8 @@ SharedSurface_ANGLEShareHandle::Create(GLContext* gl, EGLConfig config, } #endif - typedef SharedSurface_ANGLEShareHandle ptrT; - UniquePtr ret( new ptrT(gl, egl, size, hasAlpha, pbuffer, shareHandle, - keyedMutex) ); - return std::move(ret); + return MakeUnique( + gl, egl, size, hasAlpha, pbuffer, shareHandle, keyedMutex); } EGLDisplay @@ -347,9 +345,8 @@ SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl, const SurfaceCaps& caps, EGLConfig config = GLContextEGL::Cast(gl)->mConfig; - typedef SurfaceFactory_ANGLEShareHandle ptrT; - UniquePtr ret( new ptrT(gl, caps, allocator, flags, egl, config) ); - return std::move(ret); + return MakeUnique( + gl, caps, allocator, flags, egl, config); } SurfaceFactory_ANGLEShareHandle::SurfaceFactory_ANGLEShareHandle(GLContext* gl, diff --git a/gfx/gl/SharedSurfaceD3D11Interop.cpp b/gfx/gl/SharedSurfaceD3D11Interop.cpp index 4787c1d0149b..7927698c5a15 100644 --- a/gfx/gl/SharedSurfaceD3D11Interop.cpp +++ b/gfx/gl/SharedSurfaceD3D11Interop.cpp @@ -404,10 +404,9 @@ SharedSurface_D3D11Interop::Create(DXInterop2Device* interop, //// - typedef SharedSurface_D3D11Interop ptrT; - UniquePtr ret ( new ptrT(gl, size, hasAlpha, prodTex, interopFB, interopRB, - interop, lockHandle, texD3D, dxgiHandle) ); - return std::move(ret); + return MakeUnique( + gl, size, hasAlpha, prodTex, interopFB, interopRB, + interop, lockHandle, texD3D, dxgiHandle); } SharedSurface_D3D11Interop::SharedSurface_D3D11Interop(GLContext* gl, @@ -514,9 +513,8 @@ SurfaceFactory_D3D11Interop::Create(GLContext* gl, const SurfaceCaps& caps, return nullptr; } - typedef SurfaceFactory_D3D11Interop ptrT; - UniquePtr ret(new ptrT(gl, caps, allocator, flags, interop)); - return std::move(ret); + return MakeUnique( + gl, caps, allocator, flags, interop); } SurfaceFactory_D3D11Interop::SurfaceFactory_D3D11Interop(GLContext* gl, diff --git a/ipc/mscom/PassthruProxy.cpp b/ipc/mscom/PassthruProxy.cpp index e6a897d3df7f..3101334945f6 100644 --- a/ipc/mscom/PassthruProxy.cpp +++ b/ipc/mscom/PassthruProxy.cpp @@ -34,7 +34,7 @@ PassthruProxy::PassthruProxy(ProxyStream::Environment* aEnv, REFIID aIidToWrap, { ProxyStream proxyStream(aIidToWrap, aObjToWrap, aEnv, ProxyStreamFlags::ePreservable); - mPreservedStream = std::move(proxyStream.GetPreservedStream()); + mPreservedStream = proxyStream.GetPreservedStream(); MOZ_ASSERT(mPreservedStream); }