Skip to content

STYLE: ImageFileReader uses std::unique_ptr<[]>, try-catch-throw removed#638

Merged
thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:ImageFileReader-unique_ptr
Mar 28, 2019
Merged

STYLE: ImageFileReader uses std::unique_ptr<[]>, try-catch-throw removed#638
thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:ImageFileReader-unique_ptr

Conversation

@N-Dekker
Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker commented Mar 27, 2019

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.

@N-Dekker
Copy link
Copy Markdown
Contributor Author

The next amend (force-push) will just adjust the commit text a little bit.

@N-Dekker N-Dekker changed the title STYLE: ImageFileReader using std::unique_ptr<[]> instead of try-catch STYLE: ImageFileReader uses std::unique_ptr<[]>, try-catch-throw removed Mar 27, 2019
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.
@N-Dekker
Copy link
Copy Markdown
Contributor Author

When reviewing this commit, you might want to ignore lines that only have white space differences:
https://github.blog/2018-05-01-ignore-white-space-in-code-review/

When removing the try-catch, I had to adjust the indentation, that's why there are those white space differences!

@phcerdan phcerdan self-requested a review March 27, 2019 17:46
Copy link
Copy Markdown
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

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

Nice @N-Dekker !

@thewtex thewtex merged commit af5a691 into InsightSoftwareConsortium:master 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants