Skip to content

Remove local type aliases of IteratorWithIndex in *.hxx files#5839

Merged
hjmjohnson merged 3 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:Remove-local-type-aliases-IteratorWithIndex
Feb 27, 2026
Merged

Remove local type aliases of IteratorWithIndex in *.hxx files#5839
hjmjohnson merged 3 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:Remove-local-type-aliases-IteratorWithIndex

Conversation

@N-Dekker
Copy link
Contributor

@N-Dekker N-Dekker commented Feb 26, 2026

Made it easier to figure out when an iterator "with index" is being used.

Using Notepad++, Replace in Files, doing:

Find what: ^[ ]+ using (\w+) = (Image\w+IteratorWithIndex<\w+>);\r\n(.*?[^\w])\1
Replace with: $3$2
(*) Regular expression
[v] . matches newline

BinomialBlurImageFilter and CheckerBoardImageFilter were adjusted manually.


Note: it appears that some filters accidentally use an iterator "with index", while they should have used a different iterator type, for performance reasons. Such possible mistakes should be easier to spot when it is directly obvious from the iterator variable declarations that those iterators are "with index".

When reviewing, it might be helpful to ignore whitespace changes: https://github.com/InsightSoftwareConsortium/ITK/pull/5839/changes?w=1

Made it easier to figure out when an iterator "with index" is being used.
Made it easier to figure out when an iterator "with index" is being used.
Made it easier to figure out when an iterator "with index" is being used.

Using Notepad++, Replace in Files, doing:

    Find what: ^[ ]+ using (\w+) = (Image\w+IteratorWithIndex<\w+>);\r\n(.*?[^\w])\1
    Replace with: $3$2
    (*) Regular expression
    [v] . matches newline
@github-actions github-actions bot added area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module area:Video Issues affecting the Video module area:Numerics Issues affecting the Numerics module labels Feb 26, 2026
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mild approval. Reservation: this sometimes makes the iterator declaration span multiple lines.

@N-Dekker
Copy link
Contributor Author

Mild approval. Reservation: this sometimes makes the iterator declaration span multiple lines.

Thanks @dzenanz As far as I can see, it only happens a few times that these iterator declaration span multiple lines. Most cases still fit on a line.

Other mitigating factors:

  • We did already shorten various iterator declarations very recently by pull request Remove itk::, when using Iterator type in itk namespace #5818
  • We could reconsider using CTAD (class template argument deduction) for "WithIndex" variables, as a follow-up PR, so that we don't need to explicitly specify the template argument (usually TInputImage or TOutputImage) with each variable declaration.
  • It appears that some of the iterators don't really need to be "with index". Removing WithIndex in those cases will shorten those iterator variable declaration.

@N-Dekker N-Dekker marked this pull request as ready for review February 26, 2026 17:55
@hjmjohnson hjmjohnson merged commit 24c2613 into InsightSoftwareConsortium:main Feb 27, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:Numerics Issues affecting the Numerics module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module area:Video Issues affecting the Video module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants