Add and use itk::ImageBase::AllocateInitialized()#4479
Conversation
|
/azp run |
|
I find the member function name over verbose. |
|
|
Thanks for the suggestion @dzenanz. However, I would like the name to be self-explanatory. Until now it was a common practice to add a comment to actually explain the meaning of So do you (both) think the name |
I think the name is sufficient 👍 |
Equivalent to `Allocate(true)`. Aims to help improve readability of user code.
Replaced function calls of the form `image->Allocate(true)` with `image->AllocateInitialized()`. Removed redundant comments that said something like `// initialize buffer to zero`.
492c355 to
527843e
Compare
itk::ImageBase::AllocateZeroInitializedPixelBuffer()itk::ImageBase::AllocateInitialized()
Replaced lines of code of the form
image>Allocate();
image>FillBuffer(zero);
With `image->AllocateInitialized();`.
Follow-up to pull request InsightSoftwareConsortium#4479
commit 47fe345
"ENH: Add `AllocateInitialized()` to ImageBase"
Replaced lines of code of the form
image>Allocate();
image>FillBuffer(zero);
With `image->AllocateInitialized();`.
Cases found by the regular expression `^(.+->)Allocate.+;\r\n\1FillBuffer`.
Follow-up to pull request InsightSoftwareConsortium#4479
commit 47fe345
"ENH: Add `AllocateInitialized()` to ImageBase"
Following ITK pull request InsightSoftwareConsortium/ITK#4479 commit InsightSoftwareConsortium/ITK@47fe345 "ENH: Add `AllocateInitialized()` to ImageBase".
Following ITK pull request InsightSoftwareConsortium/ITK#4479 commit InsightSoftwareConsortium/ITK@47fe345 "ENH: Add `AllocateInitialized()` to ImageBase".
Following ITK pull request InsightSoftwareConsortium/ITK#4479 commit InsightSoftwareConsortium/ITK@47fe345 "ENH: Add `AllocateInitialized()` to ImageBase".
Following ITK pull request InsightSoftwareConsortium/ITK#4479 commit InsightSoftwareConsortium/ITK@47fe345 "ENH: Add `AllocateInitialized()` to ImageBase".
Following ITK pull request InsightSoftwareConsortium/ITK#4479 commit InsightSoftwareConsortium/ITK@47fe345 "ENH: Add `AllocateInitialized()` to ImageBase".
Following ITK pull request InsightSoftwareConsortium/ITK#4479 commit InsightSoftwareConsortium/ITK@47fe345 "ENH: Add `AllocateInitialized()` to ImageBase".
The existing three possible ways to call
Allocate(bool = false)(either byAllocate(true),Allocate(false), orAllocate()) may accidentally be confused, especially by novice ITK users.The proposed
AllocateZeroInitializedPixelBuffer()is intended to reduce the chance of such a confusion, and improve code readability. It is equivalent toAllocate(true).For the record, "AllocateZeroInitializedPixelBuffer" was renamed to "AllocateInitialized", as suggested at #4479 (comment)