Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Replace T var{ NumericTraits<T>::ZeroValue() } with T var{} #4017

Conversation

N-Dekker
Copy link
Contributor

Replaced brace-initialization by NumericTraits<T>::ZeroValue() with empty {} initializers. Did so by Replace in Files, using regular expressions:

Find what: (\w.+)( .+){ NumericTraits<\1>::ZeroValue\(\) };
Replace with:  $1$2{};

Follow-up to pull request #3958 commit 42b0bfc
"STYLE: Replace T var = NumericTraits<T>::ZeroValue() with T var{}"

Replaced brace-initialization by `NumericTraits<T>::ZeroValue()` with empty `{}`
initializers. Did so by Replace in Files, using regular expressions:

    Find what: (\w.+)( .+){ NumericTraits<\1>::ZeroValue\(\) };
    Replace with:  $1$2{};

Follow-up to pull request InsightSoftwareConsortium#3958
commit 42b0bfc
"STYLE: Replace `T var = NumericTraits<T>::ZeroValue()` with `T var{}`"
@github-actions github-actions bot added area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module type:Style Style changes: no logic impact (indentation, comments, naming) labels Apr 19, 2023
@N-Dekker N-Dekker marked this pull request as ready for review April 19, 2023 18:39
@N-Dekker N-Dekker requested a review from hjmjohnson April 19, 2023 19:07
@dzenanz dzenanz merged commit 5ac803e into InsightSoftwareConsortium:master Apr 20, 2023
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Feb 12, 2024
For any type 'T` that is supported by `NumericTraits<T>`, the expression
`NumericTraits<T>::ZeroValue()` is just equivalent to `T{}`. `T{}` is preferred,
because it is more generic, and it may yield faster code than the corresponding
`NumericTraits<T>::ZeroValue()` function call.

Using Notepad++ Replace in Files:

    Find what: itk::NumericTraits<(\w+)>::ZeroValue\(\)
    Find what: NumericTraits<(\w+)>::ZeroValue\(\)
    Replace with: $1{}
    Filters: itk*.hxx;itk*.h;itk*.cxx
    Directory: ITK\Modules
    [v] Match case
    (*) Regular expression

Excluded "itkNumericTraitsTest.cxx", because it is meant to test
`NumericTraits::ZeroValue()`.

Follow-up to pull request InsightSoftwareConsortium#4017
commit 5ac803e
"STYLE: Replace `T var{ NumericTraits<T>::ZeroValue() }` with `T var{}`"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Feb 12, 2024
For any type `T` that is supported by `NumericTraits<T>`, the expression
`NumericTraits<T>::ZeroValue()` is just equivalent to `T{}`. `T{}` is preferred,
because it is more generic, and it may yield faster code than the corresponding
`NumericTraits<T>::ZeroValue()` function call.

Using Notepad++ Replace in Files:

    Find what: itk::NumericTraits<(\w+)>::ZeroValue\(\)
    Find what: NumericTraits<(\w+)>::ZeroValue\(\)
    Replace with: $1{}
    Filters: itk*.hxx;itk*.h;itk*.cxx
    Directory: ITK\Modules
    [v] Match case
    (*) Regular expression

Excluded "itkNumericTraitsTest.cxx", because it is meant to test
`NumericTraits::ZeroValue()`.

Follow-up to pull request InsightSoftwareConsortium#4017
commit 5ac803e
"STYLE: Replace `T var{ NumericTraits<T>::ZeroValue() }` with `T var{}`"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Feb 12, 2024
For any type `T` that is supported by `NumericTraits<T>`, the expression
`NumericTraits<T>::ZeroValue()` is just equivalent to `T{}`. `T{}` appears
preferred, because it is more generic, and it may yield faster code than the
corresponding `NumericTraits<T>::ZeroValue()` function call.

Using Notepad++, Replace in Files:

    Find what: itk::NumericTraits<(\w+)>::ZeroValue\(\)
    Find what: NumericTraits<(\w+)>::ZeroValue\(\)
    Replace with: $1{}
    Filters: itk*.hxx;itk*.h;itk*.cxx
    Directory: ITK\Modules
    [v] Match case
    (*) Regular expression

Excluded "itkNumericTraitsTest.cxx", because it purposely calls
`NumericTraits::ZeroValue()` as part of the test.

Follow-up to pull request InsightSoftwareConsortium#4017
commit 5ac803e
"STYLE: Replace `T var{ NumericTraits<T>::ZeroValue() }` with `T var{}`"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Feb 13, 2024
For any type `T` that is supported by `NumericTraits<T>`, the expression
`NumericTraits<T>::ZeroValue()` is just equivalent to `T{}`. `T{}` appears
preferable, because it is more generic, and it may yield faster code than the
corresponding `NumericTraits<T>::ZeroValue()` function call.

Using Notepad++, Replace in Files:

    Find what:
      itk::NumericTraits<(\w+)>::ZeroValue\(\)
      NumericTraits<(\w+)>::ZeroValue\(\)
      itk::NumericTraits<([^ <>]+)>::ZeroValue\(\)
      NumericTraits<([^ <>]+)>::ZeroValue\(\)
      itk::NumericTraits<(typename [^ <>]+)>::ZeroValue\(\)
      NumericTraits<(typename [^ <>]+)>::ZeroValue\(\)
      itk::NumericTraits<(itk::NumericTraits<[^ ]+>::ValueType)>::ZeroValue\(\)
      itk::NumericTraits<(typename itk::NumericTraits<[^ ]+>::ValueType)>::ZeroValue\(\)
      NumericTraits<(typename NumericTraits<[^ ]+>::ValueType)>::ZeroValue\(\)
      itk::NumericTraits<(typename .+)>::ZeroValue\(\)
      NumericTraits<(typename .+)>::ZeroValue\(\)
    Replace with: $1{}
    Filters: itk*.hxx;itk*.h;itk*.cxx
    Directory: ITK\Modules
    [v] Match case
    (*) Regular expression

Excluded "itkNumericTraitsTest.cxx", because it purposely calls
`NumericTraits::ZeroValue()` as part of the test.

Follow-up to pull request InsightSoftwareConsortium#4017
commit 5ac803e
"STYLE: Replace `T var{ NumericTraits<T>::ZeroValue() }` with `T var{}`"
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 type:Style Style changes: no logic impact (indentation, comments, naming)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants