STYLE: ImageFileReader uses std::unique_ptr<[]>, try-catch-throw removed#638
Merged
thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom Mar 28, 2019
N-Dekker:ImageFileReader-unique_ptr
Merged
STYLE: ImageFileReader uses std::unique_ptr<[]>, try-catch-throw removed#638thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom N-Dekker:ImageFileReader-unique_ptr
thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:ImageFileReader-unique_ptr
Conversation
Contributor
Author
|
The next amend (force-push) will just adjust the commit text a little bit. |
Simplified `ImageFileReader::GenerateData()` implementation by declaring its local `loadBuffer` as `const std::unique_ptr<char[]>`, instead of as a raw `char` pointer. Removed try-catch-throw and `delete[]` statements that are no longer necessary now, due to the C++ "RAII" idiom implemented by `std::unique_ptr`. Replaced a `std::copy` by `std::copy_n`, to further simplify the code.
Contributor
Author
|
When reviewing this commit, you might want to ignore lines that only have white space differences: When removing the try-catch, I had to adjust the indentation, that's why there are those white space differences! |
fbudin69500
approved these changes
Mar 27, 2019
phcerdan
approved these changes
Mar 27, 2019
thewtex
approved these changes
Mar 28, 2019
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
…ileReader-unique_ptr STYLE: ImageFileReader uses std::unique_ptr<[]>, try-catch-throw removed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Simplified
ImageFileReader::GenerateData()implementation by declaringits local
loadBufferasconst std::unique_ptr<char[]>, instead of asa raw
charpointer.Removed try-catch-throw and
delete[]statements that are no longer necessarynow, due to the C++ "RAII" idiom implemented by
std::unique_ptr.Replaced a
std::copybystd::copy_n, to further simplify the code.