Replaced _countof / ARRAYSIZE with std::size

This commit is contained in:
Chuck Walbourn
2021-01-02 12:44:35 -08:00
parent 2f8e8120ae
commit f764da5176
15 changed files with 38 additions and 37 deletions

View File

@@ -11,7 +11,6 @@
#pragma once
#include <assert.h>
#include <DirectXMath.h>
#include <DirectXPackedVector.h>

View File

@@ -1660,12 +1660,12 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const noexcept
if (ms_aModeToInfo[uMode] >= 0)
{
assert(static_cast<unsigned int>(ms_aModeToInfo[uMode]) < _countof(ms_aInfo));
_Analysis_assume_(ms_aModeToInfo[uMode] < _countof(ms_aInfo));
assert(static_cast<unsigned int>(ms_aModeToInfo[uMode]) < std::size(ms_aInfo));
_Analysis_assume_(ms_aModeToInfo[uMode] < std::size(ms_aInfo));
const ModeDescriptor* desc = ms_aDesc[ms_aModeToInfo[uMode]];
assert(static_cast<unsigned int>(ms_aModeToInfo[uMode]) < _countof(ms_aDesc));
_Analysis_assume_(ms_aModeToInfo[uMode] < _countof(ms_aDesc));
assert(static_cast<unsigned int>(ms_aModeToInfo[uMode]) < std::size(ms_aDesc));
_Analysis_assume_(ms_aModeToInfo[uMode] < std::size(ms_aDesc));
const ModeInfo& info = ms_aInfo[ms_aModeToInfo[uMode]];
INTEndPntPair aEndPts[BC6H_MAX_REGIONS] = {};
@@ -1811,7 +1811,7 @@ void D3DX_BC6H::Encode(bool bSigned, const HDRColorA* const pIn) noexcept
EncodeParams EP(pIn, bSigned);
for (EP.uMode = 0; EP.uMode < ARRAYSIZE(ms_aInfo) && EP.fBestErr > 0; ++EP.uMode)
for (EP.uMode = 0; EP.uMode < std::size(ms_aInfo) && EP.fBestErr > 0; ++EP.uMode)
{
const uint8_t uShapes = ms_aInfo[EP.uMode].uPartitions ? 32u : 1u;
// Number of rough cases to look at. reasonable values of this are 1, uShapes/4, and uShapes

View File

@@ -2988,9 +2988,9 @@ uint32_t DirectX::_GetConvertFlags(DXGI_FORMAT format) noexcept
{
#ifdef _DEBUG
// Ensure conversion table is in ascending order
assert(_countof(g_ConvertTable) > 0);
assert(std::size(g_ConvertTable) > 0);
DXGI_FORMAT lastvalue = g_ConvertTable[0].format;
for (size_t index = 1; index < _countof(g_ConvertTable); ++index)
for (size_t index = 1; index < std::size(g_ConvertTable); ++index)
{
assert(g_ConvertTable[index].format > lastvalue);
lastvalue = g_ConvertTable[index].format;
@@ -2998,7 +2998,7 @@ uint32_t DirectX::_GetConvertFlags(DXGI_FORMAT format) noexcept
#endif
ConvertData key = { format, 0, 0 };
auto in = reinterpret_cast<const ConvertData*>(bsearch_s(&key, g_ConvertTable, _countof(g_ConvertTable), sizeof(ConvertData),
auto in = reinterpret_cast<const ConvertData*>(bsearch_s(&key, g_ConvertTable, std::size(g_ConvertTable), sizeof(ConvertData),
ConvertCompare, nullptr));
return (in) ? in->flags : 0;
}
@@ -3020,9 +3020,9 @@ void DirectX::_ConvertScanline(
#ifdef _DEBUG
// Ensure conversion table is in ascending order
assert(_countof(g_ConvertTable) > 0);
assert(std::size(g_ConvertTable) > 0);
DXGI_FORMAT lastvalue = g_ConvertTable[0].format;
for (size_t index = 1; index < _countof(g_ConvertTable); ++index)
for (size_t index = 1; index < std::size(g_ConvertTable); ++index)
{
assert(g_ConvertTable[index].format > lastvalue);
lastvalue = g_ConvertTable[index].format;
@@ -3032,10 +3032,10 @@ void DirectX::_ConvertScanline(
// Determine conversion details about source and dest formats
ConvertData key = { inFormat, 0, 0 };
auto in = reinterpret_cast<const ConvertData*>(
bsearch_s(&key, g_ConvertTable, _countof(g_ConvertTable), sizeof(ConvertData), ConvertCompare, nullptr));
bsearch_s(&key, g_ConvertTable, std::size(g_ConvertTable), sizeof(ConvertData), ConvertCompare, nullptr));
key.format = outFormat;
auto out = reinterpret_cast<const ConvertData*>(
bsearch_s(&key, g_ConvertTable, _countof(g_ConvertTable), sizeof(ConvertData), ConvertCompare, nullptr));
bsearch_s(&key, g_ConvertTable, std::size(g_ConvertTable), sizeof(ConvertData), ConvertCompare, nullptr));
if (!in || !out)
{
assert(false);

View File

@@ -114,6 +114,7 @@
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <iterator>
#include <memory>
#include <DirectXPackedVector.h>

View File

@@ -123,7 +123,7 @@ namespace
_Use_decl_annotations_
DXGI_FORMAT DirectX::_WICToDXGI(const GUID& guid) noexcept
{
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
for (size_t i = 0; i < std::size(g_WICFormats); ++i)
{
if (memcmp(&g_WICFormats[i].wic, &guid, sizeof(GUID)) == 0)
return g_WICFormats[i].format;
@@ -186,7 +186,7 @@ bool DirectX::_DXGIToWIC(DXGI_FORMAT format, GUID& guid, bool ignoreRGBvsBGR) no
#endif
default:
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
for (size_t i = 0; i < std::size(g_WICFormats); ++i)
{
if (g_WICFormats[i].format == format)
{
@@ -205,7 +205,7 @@ TEX_FILTER_FLAGS DirectX::_CheckWICColorSpace(_In_ const GUID& sourceGUID, _In_
{
TEX_FILTER_FLAGS srgb = TEX_FILTER_DEFAULT;
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
for (size_t i = 0; i < std::size(g_WICFormats); ++i)
{
if (memcmp(&g_WICFormats[i].wic, &sourceGUID, sizeof(GUID)) == 0)
{

View File

@@ -200,7 +200,7 @@ namespace
}
else
{
for (size_t i = 0; i < _countof(g_WICConvert); ++i)
for (size_t i = 0; i < std::size(g_WICConvert); ++i)
{
if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0)
{

View File

@@ -9,8 +9,9 @@
#pragma once
#include <assert.h>
#include <cassert>
#include <memory>
#include <malloc.h>
//---------------------------------------------------------------------------------