Skip to content

Commit fe96138

Browse files
authored
Merge pull request InsightSoftwareConsortium#6014 from hjmjohnson/style-sizetype-filled-assign
STYLE: Replace declare-then-assign with const auto for FixedArray-based types
2 parents f7d1ed8 + c79c308 commit fe96138

File tree

42 files changed

+152
-291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+152
-291
lines changed

Modules/Core/Common/test/itkAnnulusOperatorGTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ TEST(AnnulusOperator, CreateAndInspect)
4747

4848
EXPECT_NO_THROW(normalizedAnnulus.CreateOperator());
4949

50-
OperatorType::SizeType normalizedAnnulusSize;
51-
normalizedAnnulusSize = normalizedAnnulus.GetSize();
50+
const OperatorType::SizeType normalizedAnnulusSize = normalizedAnnulus.GetSize();
5251

5352
std::cout << std::endl;
5453
std::cout << "Annulus, N = " << normalizedAnnulusSize << ", r = " << normalizedAnnulus.GetInnerRadius()

Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionTest.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,8 @@ itkBSplineInterpolationWeightFunctionTest(int, char *[])
255255
std::cout << "Number Of Weights: " << numberOfWeights << std::endl;
256256

257257
auto position = itk::MakeFilled<ContinuousIndexType>(4.15);
258-
WeightsType weights;
259258
IndexType startIndex;
260-
261-
weights = function->Evaluate(position);
259+
WeightsType weights = function->Evaluate(position);
262260

263261
std::cout << "Position: " << position << std::endl;
264262
std::cout << "Weights: " << weights << std::endl;

Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexGTest.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,11 @@ TEST(ImageRandomNonRepeatingIteratorWithIndex, SupportsSubregions)
8282
it.SetNumberOfSamples(numberOfPixelsSize0);
8383
it.GoToBegin();
8484
{
85-
ImageType::IndexType indexFill0;
8685
// Because the random iterator does not repeat, this should
8786
// fill the image with indices
8887
while (!it.IsAtEnd())
8988
{
90-
indexFill0 = it.GetIndex();
89+
const ImageType::IndexType indexFill0 = it.GetIndex();
9190
it.Set(indexFill0);
9291
++it;
9392
}
@@ -117,10 +116,9 @@ TEST(ImageRandomNonRepeatingIteratorWithIndex, SupportsSubregions)
117116

118117
std::cout << "Verifying const iterator... ";
119118
std::cout << "Random walk of the Iterator over the image " << std::endl;
120-
ImageType::IndexType indexConstMatch;
121119
while (!cot.IsAtEnd())
122120
{
123-
indexConstMatch = cot.GetIndex();
121+
const ImageType::IndexType indexConstMatch = cot.GetIndex();
124122
EXPECT_EQ(cot.Get(), indexConstMatch)
125123
<< "Values don't correspond to what was stored " << std::endl
126124
<< "Test failed at index " << indexConstMatch << " value is " << cot.Get() << std::endl;

Modules/Core/Common/test/itkVersorTest.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ itkVersorTest(int, char *[])
271271
const ValueType cosangle = std::cos(angle / 2.0);
272272
const ValueType sinangle = std::sin(angle / 2.0);
273273

274-
VectorType xb;
275-
276-
xb = xa * sinangle;
274+
const VectorType xb = xa * sinangle;
277275

278276
if (itk::Math::Absolute(qa.GetX() - xb[0]) > epsilon)
279277
{

Modules/Core/ImageFunction/test/itkBSplineInterpolateImageFunctionTest.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,9 @@ TestContinuousIndexDerivative(const TInterpolator * interp,
220220

221221
if (isInside)
222222
{
223-
typename TInterpolator::CovariantVectorType value;
224-
const double value2 = interp->EvaluateAtContinuousIndex(index);
223+
const double value2 = interp->EvaluateAtContinuousIndex(index);
225224
std::cout << "Interpolated Value: " << value2 << '\n';
226-
value = interp->EvaluateDerivativeAtContinuousIndex(index);
225+
const typename TInterpolator::CovariantVectorType value = interp->EvaluateDerivativeAtContinuousIndex(index);
227226
std::cout << " Value: ";
228227
for (int i = 0; i < ImageDimension3D; ++i)
229228
{

Modules/Core/Transform/test/itkBSplineDeformableTransformTest2.cxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,15 @@ class BSplineDeformableTransformTest2Helper
204204

205205
fi.GoToBegin();
206206

207-
typename TransformType::InputPointType fixedPoint;
208-
typename TransformType::OutputPointType movingPoint;
209-
typename DeformationFieldType::IndexType index;
207+
typename TransformType::InputPointType fixedPoint;
210208

211209
VectorType displacement;
212210

213211
while (!fi.IsAtEnd())
214212
{
215-
index = fi.ComputeIndex();
213+
const typename DeformationFieldType::IndexType index = fi.ComputeIndex();
216214
field->TransformIndexToPhysicalPoint(index, fixedPoint);
217-
movingPoint = bsplineTransform->TransformPoint(fixedPoint);
215+
const typename TransformType::OutputPointType movingPoint = bsplineTransform->TransformPoint(fixedPoint);
218216
displacement[0] = movingPoint[0] - fixedPoint[0];
219217
displacement[1] = movingPoint[1] - fixedPoint[1];
220218
fi.Set(displacement);

Modules/Core/Transform/test/itkBSplineDeformableTransformTest3.cxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,15 @@ class BSplineDeformableTransformTest3Helper
218218

219219
fi.GoToBegin();
220220

221-
typename TransformType::InputPointType fixedPoint;
222-
typename TransformType::OutputPointType movingPoint;
223-
typename DeformationFieldType::IndexType index;
221+
typename TransformType::InputPointType fixedPoint;
224222

225223
VectorType displacement;
226224

227225
while (!fi.IsAtEnd())
228226
{
229-
index = fi.ComputeIndex();
227+
const typename DeformationFieldType::IndexType index = fi.ComputeIndex();
230228
field->TransformIndexToPhysicalPoint(index, fixedPoint);
231-
movingPoint = bsplineTransform->TransformPoint(fixedPoint);
229+
const typename TransformType::OutputPointType movingPoint = bsplineTransform->TransformPoint(fixedPoint);
232230
displacement[0] = movingPoint[0] - fixedPoint[0];
233231
displacement[1] = movingPoint[1] - fixedPoint[1];
234232
fi.Set(displacement);

Modules/Core/Transform/test/itkBSplineTransformInitializerTest1.cxx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,16 @@ itkBSplineTransformInitializerTest1(int argc, char * argv[])
164164

165165
fi.GoToBegin();
166166

167-
TransformType::InputPointType fixedPoint;
168-
TransformType::OutputPointType movingPoint;
169-
TransformType::JacobianType jacobian;
170-
DeformationFieldType::IndexType index;
171-
172-
VectorType displacement;
167+
TransformType::InputPointType fixedPoint;
168+
TransformType::JacobianType jacobian;
173169

174170
while (!fi.IsAtEnd())
175171
{
176-
index = fi.ComputeIndex();
172+
const DeformationFieldType::IndexType index = fi.ComputeIndex();
177173
field->TransformIndexToPhysicalPoint(index, fixedPoint);
178-
movingPoint = bsplineTransform->TransformPoint(fixedPoint);
174+
const TransformType::OutputPointType movingPoint = bsplineTransform->TransformPoint(fixedPoint);
179175
bsplineTransform->ComputeJacobianWithRespectToParameters(fixedPoint, jacobian);
180-
displacement = movingPoint - fixedPoint;
176+
const VectorType displacement = movingPoint - fixedPoint;
181177
fi.Set(displacement);
182178
++fi;
183179
}

Modules/Core/Transform/test/itkBSplineTransformTest2.cxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,15 @@ class BSplineTransformTest2Helper
180180

181181
fi.GoToBegin();
182182

183-
typename TransformType::InputPointType fixedPoint;
184-
typename TransformType::OutputPointType movingPoint;
185-
typename DeformationFieldType::IndexType index;
183+
typename TransformType::InputPointType fixedPoint;
186184

187185
VectorType displacement;
188186

189187
while (!fi.IsAtEnd())
190188
{
191-
index = fi.ComputeIndex();
189+
const typename DeformationFieldType::IndexType index = fi.ComputeIndex();
192190
field->TransformIndexToPhysicalPoint(index, fixedPoint);
193-
movingPoint = bsplineTransform->TransformPoint(fixedPoint);
191+
const typename TransformType::OutputPointType movingPoint = bsplineTransform->TransformPoint(fixedPoint);
194192
displacement[0] = movingPoint[0] - fixedPoint[0];
195193
displacement[1] = movingPoint[1] - fixedPoint[1];
196194
fi.Set(displacement);

Modules/Core/Transform/test/itkBSplineTransformTest3.cxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,15 @@ class BSplineTransformTest3Helper
205205

206206
fi.GoToBegin();
207207

208-
typename TransformType::InputPointType fixedPoint;
209-
typename TransformType::OutputPointType movingPoint;
210-
typename DeformationFieldType::IndexType index;
208+
typename TransformType::InputPointType fixedPoint;
211209

212210
VectorType displacement;
213211

214212
while (!fi.IsAtEnd())
215213
{
216-
index = fi.ComputeIndex();
214+
const typename DeformationFieldType::IndexType index = fi.ComputeIndex();
217215
field->TransformIndexToPhysicalPoint(index, fixedPoint);
218-
movingPoint = bsplineTransform->TransformPoint(fixedPoint);
216+
const typename TransformType::OutputPointType movingPoint = bsplineTransform->TransformPoint(fixedPoint);
219217
displacement[0] = movingPoint[0] - fixedPoint[0];
220218
displacement[1] = movingPoint[1] - fixedPoint[1];
221219
fi.Set(displacement);

0 commit comments

Comments
 (0)