Simplify initialization of local region iterators in hxx files#6019
Conversation
Replaced code like `T x = T(a, b)` and `auto x = T(a, b)` with `T x(a, b)`.
Merged declaration and assignment together, for local region iterator variables. Removed `LocalLevelSetImageType` from ExtensionVelocitiesImageFilter, as it has become unnecessary with this commit.
204d82a to
d866701
Compare
|
| Filename | Overview |
|---|---|
| Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryMorphologyImageFilter.hxx | Simplifies ImageRegionIterator declaration from two-line default-construct-then-assign pattern to a single direct construction using CTAD; tmpSEImage is a SmartPointer so the explicit deduction guide applies. |
| Modules/Filtering/BinaryMathematicalMorphology/include/itkObjectMorphologyImageFilter.hxx | Replaces auto x = ImageRegionConstIterator(...) / auto y = ImageRegionIterator(...) with typed direct-initialization; semantically equivalent, both paths use CTAD. |
| Modules/Filtering/ImageFeature/include/itkHessian3DToVesselnessMeasureImageFilter.hxx | Moves oit declaration to after AllocateOutputs() and initializes it inline; this is actually a slight correctness improvement since the iterator is now constructed on already-allocated output data. |
| Modules/Filtering/ImageFeature/include/itkZeroCrossingImageFilter.hxx | Replaces ImageRegionIterator<TOutputImage> it = ImageRegionIterator(output, face) with direct CTAD initialization; cosmetic and equivalent. |
| Modules/Registration/PDEDeformable/include/itkCurvatureRegistrationFilter.hxx | Collapses five separate declare-then-assign lines into four direct-initialization declarations; CTAD deduction is correct for all four iterators (SmartPointer inputs trigger explicit guides; raw pointers use implicit constructor guides). |
| Modules/Segmentation/LevelSets/include/itkExtensionVelocitiesImageFilter.hxx | Removes now-unused LocalLevelSetImageType typedef and the early tempIt declaration, replacing the late assignment with a direct inline construction after m_Marcher->Update(); logic is unchanged. |
| Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx | Two ImageRegionIterator<BoundaryType::face_t> copy-initialize patterns simplified to direct CTAD construction; face is a SmartPointer so the explicit deduction guide fires correctly. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Old pattern:\nT x;\nx = T(a, b);\n— or —\nauto x = T(a, b);"] -->|"CTAD + direct init"| B["New pattern:\nT x(a, b);"]
B --> C{"First arg type?"}
C -->|"SmartPointer<TImage>"| D["Explicit deduction guide\nImageRegionIterator<TImage>"]
C -->|"Raw pointer\n(const TImage*)"| E["Implicit constructor guide\nImageRegionIterator<TImage>"]
D --> F["Same concrete type\nas before"]
E --> F
Reviews (1): Last reviewed commit: "STYLE: Replace declare-then-assign of re..." | Re-trigger Greptile
Replaced code like
T x; x = T(a, b),T x = T(a, b)andauto x = T(a, b)withT x(a, b), for local region iterators.Cases found, using Notepad++ with the following regular expression:
\w+ =[\r\n]*[ ]+Image\w*Iterator.