Skip to content

STYLE: Remove redundant casting for same types#5807

Merged
dzenanz merged 1 commit intomainfrom
remove-redundant-casting
Feb 16, 2026
Merged

STYLE: Remove redundant casting for same types#5807
dzenanz merged 1 commit intomainfrom
remove-redundant-casting

Conversation

@hjmjohnson
Copy link
Member

@hjmjohnson hjmjohnson commented Feb 15, 2026

STYLE: Remove redundant casting for same types

Remove explicit type casting operations that involve the same source and
destination types. Covers a range of explicit casting operations,
including static_cast, const_cast, C-style casts, and
reinterpret_cast. Its primary objective is to enhance code
readability and maintainability by eliminating unnecessary
type casting.

Cases found by clang-tidy
https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-casting.html

PR Checklist

  • No API changes were made (or the changes have been approved)

@github-actions github-actions bot added type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module area:Numerics Issues affecting the Numerics module labels Feb 15, 2026
@N-Dekker
Copy link
Contributor

Interesting, thanks Hans! How did you find these cases?

Two minor comments regarding the commit subject line, "ENH: remove redundant casting for same types"

  • I think this is not an "ENH". (It does not have new functionality). For improvements of code readability, we typically use the prefix "STYLE".
  • We have the convention to start the subject line with a capital letter. Please check https://docs.itk.org/en/latest/contributing/index.html#commit-messages
    So I would suggest: STYLE: Remove redundant casting for same types

Regarding the commit message itself:

Remove explicit type casting operations that involve the same source and
destination types, and subsequently recommend their removal.

What do you mean by "subsequently recommend their removal"?

Remove explicit type casting operations that involve the same source and
destination types. Covers a range of explicit casting operations,
including static_cast, const_cast, C-style casts, and
reinterpret_cast. Its primary objective is to enhance code
readability and maintainability by eliminating unnecessary
type casting.

Cases found by clang-tidy
https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-casting.html
@hjmjohnson hjmjohnson force-pushed the remove-redundant-casting branch from dd8e5fe to 4daf532 Compare February 15, 2026 21:04
@hjmjohnson hjmjohnson changed the title ENH: remove redundant casting for same types STYLE: Remove redundant casting for same types Feb 15, 2026
@hjmjohnson
Copy link
Member Author

Fixed comments.

Cases found by clang-tidy
https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-casting.html

Copy link
Contributor

@N-Dekker N-Dekker left a comment

Choose a reason for hiding this comment

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

Thanks Hans 👍

@dzenanz dzenanz merged commit 18886af into main Feb 16, 2026
18 checks passed
@dzenanz dzenanz deleted the remove-redundant-casting branch February 16, 2026 13:48
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:IO Issues affecting the IO module area:Numerics Issues affecting the Numerics module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants