From 827c7a892ca399fd1ddda3051ee51f7b59af2cdd Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Fri, 10 Sep 2021 09:39:14 +0200 Subject: [PATCH] [util] Replace countof with std::size --- src/d3d9/d3d9_adapter.cpp | 6 +++--- src/d3d9/d3d9_device.cpp | 2 +- src/d3d9/d3d9_fixed_function.cpp | 4 ++-- src/d3d9/d3d9_include.h | 1 - src/util/util_misc.h | 8 -------- 5 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 src/util/util_misc.h diff --git a/src/d3d9/d3d9_adapter.cpp b/src/d3d9/d3d9_adapter.cpp index 729a0f32c..69cdda0c0 100644 --- a/src/d3d9/d3d9_adapter.cpp +++ b/src/d3d9/d3d9_adapter.cpp @@ -69,9 +69,9 @@ namespace dxvk { const char* desc = options.customDeviceDesc.empty() ? props.deviceName : options.customDeviceDesc.c_str(); const char* driver = GetDriverDLL(DxvkGpuVendor(vendorId)); - std::strncpy(pIdentifier->Description, desc, countof(pIdentifier->Description)); - std::strncpy(pIdentifier->DeviceName, device.DeviceName, countof(pIdentifier->DeviceName)); // The GDI device name. Not the actual device name. - std::strncpy(pIdentifier->Driver, driver, countof(pIdentifier->Driver)); // This is the driver's dll. + std::strncpy(pIdentifier->Description, desc, std::size(pIdentifier->Description)); + std::strncpy(pIdentifier->DeviceName, device.DeviceName, std::size(pIdentifier->DeviceName)); // The GDI device name. Not the actual device name. + std::strncpy(pIdentifier->Driver, driver, std::size(pIdentifier->Driver)); // This is the driver's dll. pIdentifier->DeviceIdentifier = guid; pIdentifier->DeviceId = deviceId; diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 8047f7eee..921f29428 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -6541,7 +6541,7 @@ namespace dxvk { }); auto UploadVertexBlendData = [&](auto data) { - for (uint32_t i = 0; i < countof(data->WorldView); i++) + for (uint32_t i = 0; i < std::size(data->WorldView); i++) data->WorldView[i] = m_state.transforms[GetTransformIndex(D3DTS_VIEW)] * m_state.transforms[GetTransformIndex(D3DTS_WORLDMATRIX(i))]; }; diff --git a/src/d3d9/d3d9_fixed_function.cpp b/src/d3d9/d3d9_fixed_function.cpp index e6cd68f3e..462322e57 100644 --- a/src/d3d9/d3d9_fixed_function.cpp +++ b/src/d3d9/d3d9_fixed_function.cpp @@ -2404,7 +2404,7 @@ namespace dxvk { std::hash uint32hash; - for (uint32_t i = 0; i < countof(key.Data.Primitive); i++) + for (uint32_t i = 0; i < std::size(key.Data.Primitive); i++) state.add(uint32hash(key.Data.Primitive[i])); return state; @@ -2417,7 +2417,7 @@ namespace dxvk { std::hash uint32hash; for (uint32_t i = 0; i < caps::TextureStageCount; i++) { - for (uint32_t j = 0; j < countof(key.Stages[i].Primitive); j++) + for (uint32_t j = 0; j < std::size(key.Stages[i].Primitive); j++) state.add(uint32hash(key.Stages[i].Primitive[j])); } diff --git a/src/d3d9/d3d9_include.h b/src/d3d9/d3d9_include.h index 21dadb942..8762265ab 100644 --- a/src/d3d9/d3d9_include.h +++ b/src/d3d9/d3d9_include.h @@ -37,7 +37,6 @@ #include "../util/util_likely.h" #include "../util/util_math.h" #include "../util/util_monitor.h" -#include "../util/util_misc.h" #include "../util/util_string.h" // Missed definitions in Wine/MinGW. diff --git a/src/util/util_misc.h b/src/util/util_misc.h deleted file mode 100644 index ea9782f99..000000000 --- a/src/util/util_misc.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -namespace dxvk { - - template - size_t countof(const T(&)[n]) { return n; } - -} \ No newline at end of file