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: Update comments and parameter in the ImportImageContainer #4360

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

issakomi
Copy link
Member

@issakomi issakomi commented Dec 3, 2023

Comments and the parameter UseValueInitialization better describe the behavior of the
ImportImageContainer.
The same parameter in VectorImage has also been updated.
Also removed comment from AllocateElements about 'new' and throwing
or not throwing an exception if allocation fails.
Closes #4359

@github-actions github-actions bot added area:Core Issues affecting the Core module type:Style Style changes: no logic impact (indentation, comments, naming) labels Dec 3, 2023
@issakomi issakomi changed the title STYLE: Updated comments and variable in ImportImageContainer STYLE: Updated comments and the name of the variable in ImportImageContainer Dec 3, 2023
Comment on lines -158 to -160
// Encapsulate all image memory allocation here to throw an
// exception when memory allocation fails even when the compiler
// does not do this by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with you about removing these lines as we may assume nowadays that an exception is thrown whenever new fails to allocate the memory allocation, thanks. Just wondering if you really intended to include this change with your commit, as it's a bit of a different topic!

If we may indeed assume that new TElement[size] never returns null (as it will just return a bad_alloc exception, in case of a failure), the code may be somewhat simplified. 😃 But that would certainly be beyond the scope this commit, so you don't need to address it here. For the record, we did already assume before that new char[N] never returns null: 7482c80 (September 15, 2022)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! If you like I can put this in a separate commit or mention in the commit message. Honestly, I have forgotten to write about it in the commit message. Yes, the text seems to be not precise, it is not a preference of a compiler, of course, default new always throws std::bad_alloc. About this catch (...): probably theoretically (but unlikely) could be possible to catch an exception from a default constructor. There is similar code in itkVariableLengthVector.hxx with a better comment. If you like I could add it too.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could indeed shorten the AllocateElements implementation to something like itkVariableLengthVector.hxx, removing the if (!data) test. If you would want to do so, please make it a separate commit, or even a separate PR. But you could also leave it for now. It's up to you!

@N-Dekker
Copy link
Contributor

N-Dekker commented Dec 4, 2023

Some very minor remarks (not a show-stopper), regarding the commit message:

  • I'd rather say "parameter name" than "name of the variable"
  • We have the convention to use the "imperative mood" in the subject line of a commit message (https://docs.itk.org/en/latest/contributing/index.html), so "STYLE: Update...", rather than "STYLE: Updated...". Again, no problem, just a convention.

Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Good as-is, would be slightly better if Niels' comments were addressed. But that could be left for a follow-up PR.

@issakomi
Copy link
Member Author

issakomi commented Dec 4, 2023

Good as-is, would be slightly better if Niels' comments were addressed. But that could be left for a follow-up PR.

Thanks! Yes, I shall address comments. I am setting temporary to draft.

@issakomi issakomi marked this pull request as draft December 4, 2023 14:04
Updated comments and the parameter 'UseValueInitialization' better
describe the behavior of the ImportImageContainer.
The same parameter in VectorImage has also been updated.
Also removed comment from AllocateElements about 'new' and throwing
or not throwing an exception if allocation fails.
Closes InsightSoftwareConsortium#4359
@issakomi issakomi changed the title STYLE: Updated comments and the name of the variable in ImportImageContainer STYLE: Updated comments and parameter in ImportImageContainer Dec 5, 2023
@issakomi
Copy link
Member Author

issakomi commented Dec 5, 2023

I have updated only the message and the comment. I have added some information about removed comment about 'new', There is still one commit, I hope it is OK, the name is "Update comments ...", probably it is applicable.

@issakomi issakomi marked this pull request as ready for review December 5, 2023 14:01
@issakomi issakomi changed the title STYLE: Updated comments and parameter in ImportImageContainer STYLE: Update comments and parameter in ImportImageContainer Dec 5, 2023
@issakomi issakomi changed the title STYLE: Update comments and parameter in ImportImageContainer STYLE: Update comments and parameter in the ImportImageContainer Dec 5, 2023
Copy link
Contributor

@N-Dekker N-Dekker left a comment

Choose a reason for hiding this comment

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

Thanks @issakomi, nice 👍 Also thanks for addressing my comments so carefully!

@N-Dekker N-Dekker merged commit 3ad51b4 into InsightSoftwareConsortium:master Dec 5, 2023
12 checks passed
@issakomi issakomi deleted the init1 branch December 5, 2023 21:32
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 type:Style Style changes: no logic impact (indentation, comments, naming)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

itkImportImageContainer AllocateElements documentation doesn't seem right
3 participants