Skip to content

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

Merged
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:Replace-brace-initialization-by-NumericTraits-ZeroValue
Apr 20, 2023
Merged

STYLE: Replace T var{ NumericTraits<T>::ZeroValue() } with T var{}#4017
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:Replace-brace-initialization-by-NumericTraits-ZeroValue

Conversation

@N-Dekker
Copy link
Copy Markdown
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