Skip to content

Commit 027b946

Browse files
N-Dekkerhjmjohnson
authored andcommitted
STYLE: Replace loops doing Set(0) with AllocateInitialized(), in tests
Replaced `for (it.GoToBegin(); !it.IsAtEnd(); ++it)` loops doing `it.Set(0)` with `sourceImage->AllocateInitialized()` calls.
1 parent a8f4cfb commit 027b946

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

Modules/Core/Common/test/itkFloodFillIteratorTest.cxx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,10 @@ itkFloodFillIteratorTest(int, char *[])
6060
// the requested region to what we just defined.
6161
sourceImage->SetRegions(largestPossibleRegion);
6262
// Now allocate memory for the sourceImage
63-
sourceImage->Allocate();
63+
sourceImage->AllocateInitialized();
6464

6565
std::cout << "New sourceImage allocated" << std::endl;
6666

67-
// Initialize the image to hold all 0's
68-
itk::ImageRegionIterator<TImageType> it(sourceImage, largestPossibleRegion);
69-
70-
for (it.GoToBegin(); !it.IsAtEnd(); ++it)
71-
{
72-
it.Set(0);
73-
}
74-
7567
//---------Create and initialize a spatial function-----------
7668

7769
using TFunctionType = itk::SphereSpatialFunction<dim>;

Modules/Filtering/ImageGradient/test/itkDifferenceOfGaussiansGradientTest.cxx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,10 @@ itkDifferenceOfGaussiansGradientTest(int, char *[])
6969
// the requested region to what we just defined.
7070
sourceImage->SetRegions(largestPossibleRegion);
7171
// Now allocate memory for the sourceImage
72-
sourceImage->Allocate();
72+
sourceImage->AllocateInitialized();
7373

7474
printf("New sourceImage allocated\n");
7575

76-
// Initialize the image to hold all 0's
77-
itk::ImageRegionIterator<TImageType> it(sourceImage, largestPossibleRegion);
78-
79-
for (it.GoToBegin(); !it.IsAtEnd(); ++it)
80-
{
81-
it.Set(0);
82-
}
83-
8476
//---------Create and initialize a spatial function-----------
8577

8678
using TFunctionType = itk::SphereSpatialFunction<dim>;

0 commit comments

Comments
 (0)