Bug 1273406 - Ugly macros transform into beautiful constexpr goodness - r=cpearce
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 17 May 2016 19:32:31 +1000
changeset 297789 de61823b8e8adcc3c1a78165ec56956dbb8fd26c
parent 297788 e6d52723aa3871bcaed5c07cedc47e3e45e94204
child 297790 1585944a91831310581777033ebae204a42c32eb
push id76893
push usergsquelart@mozilla.com
push dateTue, 17 May 2016 23:00:04 +0000
treeherdermozilla-inbound@de61823b8e8a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1273406
milestone49.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 1273406 - Ugly macros transform into beautiful constexpr goodness - r=cpearce MozReview-Commit-ID: K5cyEbvPWhQ
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -148,38 +148,39 @@ WMFVideoMFTManager::GetMediaSubtypeGUID(
     case VP8: return MFVideoFormat_VP80;
     case VP9: return MFVideoFormat_VP90;
     default: return GUID_NULL;
   };
 }
 
 struct BlacklistedD3D11DLL
 {
+  constexpr
+  BlacklistedD3D11DLL(LPCWSTR aName, DWORD a, DWORD b, DWORD c, DWORD d)
+    : name(aName), ms((a << 16) | b), ls((c << 16) | d)
+  {}
   LPCWSTR name;
   DWORD ms;
   DWORD ls;
 };
-#define DLLVER(a, b, c, d) \
-        ((DWORD(a) << 16) | DWORD(b)),  ((DWORD(c) << 16) | DWORD(d))
-static const BlacklistedD3D11DLL sBlacklistedD3D11DLL[] =
+static constexpr BlacklistedD3D11DLL sBlacklistedD3D11DLL[] =
 {
   // Keep same DLL names together.
-  { L"igd10umd32.dll", DLLVER(9,17,10,2857) },
-  { L"isonyvideoprocessor.dll", DLLVER(4,1,2247,8090) },
-  { L"isonyvideoprocessor.dll", DLLVER(4,1,2153,6200) },
-  { L"tosqep.dll", DLLVER(1,2,15,526) },
-  { L"tosqep.dll", DLLVER(1,1,12,201) },
-  { L"tosqep.dll", DLLVER(1,0,11,318) },
-  { L"tosqep.dll", DLLVER(1,0,11,215) },
-  { L"tosqep64.dll", DLLVER(1,1,12,201) },
-  { L"tosqep64.dll", DLLVER(1,0,11,215) },
+  BlacklistedD3D11DLL(L"igd10umd32.dll", 9,17,10,2857),
+  BlacklistedD3D11DLL(L"isonyvideoprocessor.dll", 4,1,2247,8090),
+  BlacklistedD3D11DLL(L"isonyvideoprocessor.dll", 4,1,2153,6200),
+  BlacklistedD3D11DLL(L"tosqep.dll", 1,2,15,526),
+  BlacklistedD3D11DLL(L"tosqep.dll", 1,1,12,201),
+  BlacklistedD3D11DLL(L"tosqep.dll", 1,0,11,318),
+  BlacklistedD3D11DLL(L"tosqep.dll", 1,0,11,215),
+  BlacklistedD3D11DLL(L"tosqep64.dll", 1,1,12,201),
+  BlacklistedD3D11DLL(L"tosqep64.dll", 1,0,11,215),
   // Keep this last.
-  { nullptr, 0u, 0u }
+  BlacklistedD3D11DLL(nullptr, 0,0,0,0)
 };
-#undef DLLVER
 
 // If a blacklisted DLL is found, return its information, otherwise nullptr.
 static const BlacklistedD3D11DLL*
 IsD3D11DLLBlacklisted()
 {
   NS_ASSERTION(NS_IsMainThread(), "Must be on main thread.");
   // Cache the result, so we only check DLLs once per browser run.
   static const BlacklistedD3D11DLL* sAlreadySearched = nullptr;