Skip to content

Commit 33d10b5

Browse files
authored
Code review for const auto vs auto const (#199)
1 parent 79f067e commit 33d10b5

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

DirectXMesh/DirectXMeshConcat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ HRESULT __cdecl DirectX::ConcatenateMesh(
4141
if (newFaceCount >= UINT32_MAX || newVertCount >= UINT32_MAX)
4242
return E_FAIL;
4343

44-
auto const baseFace = static_cast<uint32_t>(totalFaces);
44+
const auto baseFace = static_cast<uint32_t>(totalFaces);
4545
for (size_t j = 0; j < nFaces; ++j)
4646
{
4747
faceDestMap[j] = baseFace + static_cast<uint32_t>(j);
4848
}
4949

50-
auto const baseVert = static_cast<uint32_t>(totalVerts);
50+
const auto baseVert = static_cast<uint32_t>(totalVerts);
5151
for (size_t j = 0; j < nVerts; ++j)
5252
{
5353
vertexDestMap[j] = baseVert + static_cast<uint32_t>(j);

DirectXMesh/DirectXMeshVBReader.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ HRESULT VBReader::Impl::Read(XMVECTOR* buffer, const char* semanticName, unsigne
452452
{
453453
if ((ptr + sizeof(uint16_t)) > eptr)
454454
return E_UNEXPECTED;
455-
auto const i = *reinterpret_cast<const uint16_t*>(ptr);
455+
const auto i = *reinterpret_cast<const uint16_t*>(ptr);
456456
float f = static_cast<float>(i) / 65535.f;
457457
if (x2bias)
458458
{
@@ -469,7 +469,7 @@ HRESULT VBReader::Impl::Read(XMVECTOR* buffer, const char* semanticName, unsigne
469469
{
470470
if ((ptr + sizeof(uint16_t)) > eptr)
471471
return E_UNEXPECTED;
472-
auto const i = *reinterpret_cast<const uint16_t*>(ptr);
472+
const auto i = *reinterpret_cast<const uint16_t*>(ptr);
473473
*buffer++ = XMVectorSet(static_cast<float>(i), 0.f, 0.f, 0.f);
474474
ptr += stride;
475475
}
@@ -480,7 +480,7 @@ HRESULT VBReader::Impl::Read(XMVECTOR* buffer, const char* semanticName, unsigne
480480
{
481481
if ((ptr + sizeof(int16_t)) > eptr)
482482
return E_UNEXPECTED;
483-
auto const i = *reinterpret_cast<const int16_t*>(ptr);
483+
const auto i = *reinterpret_cast<const int16_t*>(ptr);
484484
*buffer++ = XMVectorSet(static_cast<float>(i) / 32767.f, 0.f, 0.f, 0.f);
485485
ptr += stride;
486486
}
@@ -491,7 +491,7 @@ HRESULT VBReader::Impl::Read(XMVECTOR* buffer, const char* semanticName, unsigne
491491
{
492492
if ((ptr + sizeof(int16_t)) > eptr)
493493
return E_UNEXPECTED;
494-
auto const i = *reinterpret_cast<const int16_t*>(ptr);
494+
const auto i = *reinterpret_cast<const int16_t*>(ptr);
495495
*buffer++ = XMVectorSet(static_cast<float>(i), 0.f, 0.f, 0.f);
496496
ptr += stride;
497497
}
@@ -530,7 +530,7 @@ HRESULT VBReader::Impl::Read(XMVECTOR* buffer, const char* semanticName, unsigne
530530
{
531531
if ((ptr + sizeof(int8_t)) > eptr)
532532
return E_UNEXPECTED;
533-
auto const i = *reinterpret_cast<const int8_t*>(ptr);
533+
const auto i = *reinterpret_cast<const int8_t*>(ptr);
534534
*buffer++ = XMVectorSet(static_cast<float>(i) / 127.f, 0.f, 0.f, 0.f);
535535
ptr += stride;
536536
}
@@ -541,7 +541,7 @@ HRESULT VBReader::Impl::Read(XMVECTOR* buffer, const char* semanticName, unsigne
541541
{
542542
if ((ptr + sizeof(int8_t)) > eptr)
543543
return E_UNEXPECTED;
544-
auto const i = *reinterpret_cast<const int8_t*>(ptr);
544+
const auto i = *reinterpret_cast<const int8_t*>(ptr);
545545
*buffer++ = XMVectorSet(static_cast<float>(i), 0.f, 0.f, 0.f);
546546
ptr += stride;
547547
}

DirectXMesh/DirectXMeshletGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ namespace
674674
return E_UNEXPECTED;
675675
}
676676

677-
auto const primitive = primitiveIndices[m.PrimOffset + i];
677+
const auto primitive = primitiveIndices[m.PrimOffset + i];
678678

679679
const XMVECTOR p0 = XMLoadFloat3(&vertices[primitive.i0]);
680680

Meshconvert/Mesh.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace
7474

7575
if (length > 0)
7676
{
77-
auto const bytes = static_cast<DWORD>(sizeof(wchar_t) * length);
77+
const auto bytes = static_cast<DWORD>(sizeof(wchar_t) * length);
7878

7979
if (!WriteFile(hFile, value, bytes, &bytesWritten, nullptr))
8080
return HRESULT_FROM_WIN32(GetLastError());
@@ -1084,7 +1084,7 @@ HRESULT Mesh::ExportToVBO(const wchar_t* szFileName) const noexcept
10841084
if (FAILED(hr))
10851085
return hr;
10861086

1087-
auto const vertSize = static_cast<DWORD>(sizeof(vertex_t) * header.numVertices);
1087+
const auto vertSize = static_cast<DWORD>(sizeof(vertex_t) * header.numVertices);
10881088

10891089
DWORD bytesWritten;
10901090
if (!WriteFile(hFile.get(), vb.get(), vertSize, &bytesWritten, nullptr))
@@ -1093,7 +1093,7 @@ HRESULT Mesh::ExportToVBO(const wchar_t* szFileName) const noexcept
10931093
if (bytesWritten != vertSize)
10941094
return E_FAIL;
10951095

1096-
auto const indexSize = static_cast<DWORD>(sizeof(uint16_t) * header.numIndices);
1096+
const auto indexSize = static_cast<DWORD>(sizeof(uint16_t) * header.numIndices);
10971097

10981098
if (!WriteFile(hFile.get(), ib.get(), indexSize, &bytesWritten, nullptr))
10991099
return HRESULT_FROM_WIN32(GetLastError());
@@ -1165,7 +1165,7 @@ HRESULT Mesh::CreateFromVBO(const wchar_t* szFileName, std::unique_ptr<Mesh>& re
11651165
if (!vb || !ib)
11661166
return E_OUTOFMEMORY;
11671167

1168-
auto const vertSize = static_cast<DWORD>(sizeof(vertex_t) * header.numVertices);
1168+
const auto vertSize = static_cast<DWORD>(sizeof(vertex_t) * header.numVertices);
11691169

11701170
if (!ReadFile(hFile.get(), vb.get(), vertSize, &bytesRead, nullptr))
11711171
{
@@ -1175,7 +1175,7 @@ HRESULT Mesh::CreateFromVBO(const wchar_t* szFileName, std::unique_ptr<Mesh>& re
11751175
if (bytesRead != vertSize)
11761176
return E_FAIL;
11771177

1178-
auto const indexSize = static_cast<DWORD>(sizeof(uint16_t) * header.numIndices);
1178+
const auto indexSize = static_cast<DWORD>(sizeof(uint16_t) * header.numIndices);
11791179

11801180
if (!ReadFile(hFile.get(), ib.get(), indexSize, &bytesRead, nullptr))
11811181
{
@@ -1660,7 +1660,7 @@ HRESULT Mesh::ExportToCMO(const wchar_t* szFileName, size_t nMaterials, const Ma
16601660
if (FAILED(hr))
16611661
return hr;
16621662

1663-
auto const indexSize = static_cast<DWORD>(sizeof(uint16_t) * nIndices);
1663+
const auto indexSize = static_cast<DWORD>(sizeof(uint16_t) * nIndices);
16641664

16651665
DWORD bytesWritten;
16661666
if (!WriteFile(hFile.get(), ib.get(), indexSize, &bytesWritten, nullptr))
@@ -1680,7 +1680,7 @@ HRESULT Mesh::ExportToCMO(const wchar_t* szFileName, size_t nMaterials, const Ma
16801680
if (FAILED(hr))
16811681
return hr;
16821682

1683-
auto const vertSize = static_cast<DWORD>(sizeof(Vertex) * mnVerts);
1683+
const auto vertSize = static_cast<DWORD>(sizeof(Vertex) * mnVerts);
16841684

16851685
if (!WriteFile(hFile.get(), vb.get(), vertSize, &bytesWritten, nullptr))
16861686
return HRESULT_FROM_WIN32(GetLastError());
@@ -1701,7 +1701,7 @@ HRESULT Mesh::ExportToCMO(const wchar_t* szFileName, size_t nMaterials, const Ma
17011701
if (FAILED(hr))
17021702
return hr;
17031703

1704-
auto const skinVertSize = static_cast<DWORD>(sizeof(SkinningVertex) * mnVerts);
1704+
const auto skinVertSize = static_cast<DWORD>(sizeof(SkinningVertex) * mnVerts);
17051705

17061706
if (!WriteFile(hFile.get(), vbSkin.get(), skinVertSize, &bytesWritten, nullptr))
17071707
return HRESULT_FROM_WIN32(GetLastError());

Meshconvert/Meshconvert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
631631
for (auto pConv = conversion.begin(); pConv != conversion.end(); ++pConv)
632632
{
633633
std::filesystem::path curpath(pConv->szSrc);
634-
auto const ext = curpath.extension();
634+
const auto ext = curpath.extension();
635635

636636
if (pConv != conversion.begin())
637637
wprintf(L"\n");

0 commit comments

Comments
 (0)