Skip to content

Commit ba35e79

Browse files
authored
Code review for const auto vs auto const (#530)
1 parent f426ede commit ba35e79

14 files changed

+27
-27
lines changed

Audio/SoundCommon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ bool DirectX::IsValid(_In_ const WAVEFORMATEX* wfx) noexcept
478478

479479
if (wfex->dwChannelMask)
480480
{
481-
auto const channelBits = ChannelsSpecifiedInMask(wfex->dwChannelMask);
481+
const auto channelBits = ChannelsSpecifiedInMask(wfex->dwChannelMask);
482482
if (channelBits != wfx->nChannels)
483483
{
484484
DebugTrace("ERROR: WAVEFORMATEXTENSIBLE: nChannels=%u but ChannelMask has %u bits set\n",

Audio/SoundStreamInstance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ HRESULT SoundStreamInstance::Impl::ReadBuffers() noexcept
524524
{
525525
if (mCurrentPosition < mLengthInBytes)
526526
{
527-
auto const cbValid = static_cast<uint32_t>(std::min(mPacketSize, mLengthInBytes - mCurrentPosition));
527+
const auto cbValid = static_cast<uint32_t>(std::min(mPacketSize, mLengthInBytes - mCurrentPosition));
528528

529529
mPackets[entry].valid = cbValid;
530530
mPackets[entry].audioBytes = 0;

Src/AlphaTestEffect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void AlphaTestEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext)
202202
if (dirtyFlags & EffectDirtyFlags::AlphaTest)
203203
{
204204
// Convert reference alpha from 8 bit integer to 0-1 float format.
205-
auto const reference = static_cast<float>(referenceAlpha) / 255.0f;
205+
const auto reference = static_cast<float>(referenceAlpha) / 255.0f;
206206

207207
// Comparison tolerance of half the 8 bit integer precision.
208208
constexpr float threshold = 0.5f / 255.0f;

Src/Geometry.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ void DirectX::ComputeGeoSphere(VertexCollection& vertices, IndexCollection& indi
307307
uint16_t iv20; // index of v20
308308

309309
// Function that, when given the index of two vertices, creates a new vertex at the midpoint of those vertices.
310-
auto const divideEdge = [&](uint16_t i0, uint16_t i1, XMFLOAT3& outVertex, uint16_t& outIndex)
310+
const auto divideEdge = [&](uint16_t i0, uint16_t i1, XMFLOAT3& outVertex, uint16_t& outIndex)
311311
{
312312
const UndirectedEdge edge = makeUndirectedEdge(i0, i1);
313313

@@ -372,8 +372,8 @@ void DirectX::ComputeGeoSphere(VertexCollection& vertices, IndexCollection& indi
372372
vertices.reserve(vertexPositions.size());
373373
for (const auto& it : vertexPositions)
374374
{
375-
auto const normal = XMVector3Normalize(XMLoadFloat3(&it));
376-
auto const pos = XMVectorScale(normal, radius);
375+
const auto normal = XMVector3Normalize(XMLoadFloat3(&it));
376+
const auto pos = XMVectorScale(normal, radius);
377377

378378
XMFLOAT3 normalFloat3;
379379
XMStoreFloat3(&normalFloat3, normal);
@@ -385,7 +385,7 @@ void DirectX::ComputeGeoSphere(VertexCollection& vertices, IndexCollection& indi
385385
const float u = longitude / XM_2PI + 0.5f;
386386
const float v = latitude / XM_PI;
387387

388-
auto const texcoord = XMVectorSet(1.0f - u, v, 0.0f, 0.0f);
388+
const auto texcoord = XMVectorSet(1.0f - u, v, 0.0f, 0.0f);
389389
vertices.push_back(VertexPositionNormalTexture(pos, normal, texcoord));
390390
}
391391

@@ -468,7 +468,7 @@ void DirectX::ComputeGeoSphere(VertexCollection& vertices, IndexCollection& indi
468468
// onto a single point. In general there's no real way to do that right. But to match the behavior of non-geodesic
469469
// spheres, we need to duplicate the pole vertex for every triangle that uses it. This will introduce seams near the
470470
// poles, but reduce stretching.
471-
auto const fixPole = [&](size_t poleIndex)
471+
const auto fixPole = [&](size_t poleIndex)
472472
{
473473
const auto& poleVertex = vertices[poleIndex];
474474
bool overwrittenPoleVertex = false; // overwriting the original pole vertex saves us one vertex

Src/LoaderHelpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ namespace DirectX
340340
}
341341

342342
// DDS files always start with the same magic number ("DDS ")
343-
auto const dwMagicNumber = *reinterpret_cast<const uint32_t*>(ddsData);
343+
const auto dwMagicNumber = *reinterpret_cast<const uint32_t*>(ddsData);
344344
if (dwMagicNumber != DDS_MAGIC)
345345
{
346346
return E_FAIL;
@@ -450,7 +450,7 @@ namespace DirectX
450450
}
451451

452452
// DDS files always start with the same magic number ("DDS ")
453-
auto const dwMagicNumber = *reinterpret_cast<const uint32_t*>(ddsData.get());
453+
const auto dwMagicNumber = *reinterpret_cast<const uint32_t*>(ddsData.get());
454454
if (dwMagicNumber != DDS_MAGIC)
455455
{
456456
ddsData.reset();
@@ -963,7 +963,7 @@ namespace DirectX
963963
if (MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC)
964964
{
965965
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>(reinterpret_cast<const uint8_t*>(header) + sizeof(DDS_HEADER));
966-
auto const mode = static_cast<DDS_ALPHA_MODE>(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK);
966+
const auto mode = static_cast<DDS_ALPHA_MODE>(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK);
967967
switch (mode)
968968
{
969969
case DDS_ALPHA_MODE_STRAIGHT:

Src/ModelLoadCMO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO(
297297
throw std::runtime_error("IB too large for DirectX 11");
298298
}
299299

300-
auto const ibBytes = static_cast<size_t>(sizeInBytes);
300+
const auto ibBytes = static_cast<size_t>(sizeInBytes);
301301

302302
auto indexes = reinterpret_cast<const uint16_t*>(meshData + usedSize);
303303
usedSize += ibBytes;

Src/ModelLoadSDKMESH.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH(
641641
mesh->meshParts.reserve(mh.NumSubsets);
642642
for (size_t j = 0; j < mh.NumSubsets; ++j)
643643
{
644-
auto const sIndex = subsets[j];
644+
const auto sIndex = subsets[j];
645645
if (sIndex >= header->NumTotalSubsets)
646646
throw std::out_of_range("Invalid mesh found");
647647

Src/ModelLoadVBO.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ std::unique_ptr<Model> DirectX::Model::CreateFromVBO(
7777
throw std::runtime_error("VB too large for DirectX 11");
7878
}
7979

80-
auto const vertSize = static_cast<size_t>(sizeInBytes);
80+
const auto vertSize = static_cast<size_t>(sizeInBytes);
8181

8282
if (dataSize < (vertSize + sizeof(VBO::header_t)))
8383
throw std::runtime_error("End of file");
@@ -94,7 +94,7 @@ std::unique_ptr<Model> DirectX::Model::CreateFromVBO(
9494
throw std::runtime_error("IB too large for DirectX 11");
9595
}
9696

97-
auto const indexSize = static_cast<size_t>(sizeInBytes);
97+
const auto indexSize = static_cast<size_t>(sizeInBytes);
9898

9999
if (dataSize < (sizeof(VBO::header_t) + vertSize + indexSize))
100100
throw std::runtime_error("End of file");

Src/Mouse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,8 +1443,8 @@ void Mouse::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
14431443
const int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
14441444
const int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
14451445

1446-
auto const x = static_cast<int>((float(raw.data.mouse.lLastX) / 65535.0f) * float(width));
1447-
auto const y = static_cast<int>((float(raw.data.mouse.lLastY) / 65535.0f) * float(height));
1446+
const auto x = static_cast<int>((float(raw.data.mouse.lLastX) / 65535.0f) * float(width));
1447+
const auto y = static_cast<int>((float(raw.data.mouse.lLastY) / 65535.0f) * float(height));
14481448

14491449
if (pImpl->mRelativeX == INT32_MAX)
14501450
{

Src/SharedResourcePool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace DirectX
9393
{
9494
const std::lock_guard<std::mutex> lock(mResourceMap->mutex);
9595

96-
auto const pos = mResourceMap->find(mKey);
96+
const auto pos = mResourceMap->find(mKey);
9797

9898
// Check for weak reference expiry before erasing, in case DemandCreate runs on
9999
// a different thread at the same time as a previous instance is being destroyed.

0 commit comments

Comments
 (0)