Skip to content

Commit 4be530e

Browse files
committed
STYLE: Avoid multiple GetIndex() calls in ContourExtractor2DImageFilter
Avoided calling `inputIt.GetIndex()` repetitively during one and the same iteration. This is just a style improvement, as it is not a major performance improvement. (`inputIt.GetIndex()` is likely to be very fast.)
1 parent 2e75b53 commit 4be530e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,12 @@ ContourExtractor2DImageFilter<TInputImage>::GenerateDataForLabels()
353353
ImageRegionConstIteratorWithIndex<TInputImage> inputIt{ input, inputRegion };
354354
for (inputIt.GoToBegin(); !inputIt.IsAtEnd(); ++inputIt)
355355
{
356+
const auto & index = inputIt.GetIndex();
356357
BoundingBoxType & bbox = labelBoundingBoxes[inputIt.Get()];
357-
bbox.min[0] = std::min(bbox.min[0], inputIt.GetIndex()[0]);
358-
bbox.min[1] = std::min(bbox.min[1], inputIt.GetIndex()[1]);
359-
bbox.max[0] = std::max(bbox.max[0], inputIt.GetIndex()[0]);
360-
bbox.max[1] = std::max(bbox.max[1], inputIt.GetIndex()[1]);
358+
bbox.min[0] = std::min(bbox.min[0], index[0]);
359+
bbox.min[1] = std::min(bbox.min[1], index[1]);
360+
bbox.max[0] = std::max(bbox.max[0], index[0]);
361+
bbox.max[1] = std::max(bbox.max[1], index[1]);
361362
}
362363
// Build the extended regions from the bounding boxes
363364
for (const InputPixelType label : allLabels)

0 commit comments

Comments
 (0)