-
-
Notifications
You must be signed in to change notification settings - Fork 715
Remove AllocateElements from VariableLengthVector #5710
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
Remove AllocateElements from VariableLengthVector #5710
Conversation
| : m_Data(nullptr) | ||
| : m_Data(new TValue[length]) | ||
| { | ||
| Reserve(length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified the VariableLengthVector(length) constructor by removing its internal Reserve(length) call.
It appears unnecessary for VariableLengthVector to replace exceptions from `new T[n]` with ITK exceptions. This commit also simplified the `VariableLengthVector(length)` constructor.
Although AllocateElements is a public member function of VariableLengthVector, it was only used internally, by VariableLengthVector itself.
a222c4d to
f080d4f
Compare
blowekamp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look good to me.
dzenanz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good on a glance.
thewtex
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
|
Valgrind seems to be complaining |
Thanks @issakomi, but as far as I can see, those failures are unrelated to this PR (Remove AllocateElements from VariableLengthVector). I see, https://open.cdash.org/builds/10917349/dynamic_analysis/11341974 says:
|
MaskedAssignFixture.SetGetPrint failed, I am talking about other tests with Valgring defects: |
VariableLengthVector::AllocateElementsjust converted any possible exception fromnew TValue[size]to an ITK exception:ITK/Modules/Core/Common/include/itkVariableLengthVector.hxx
Lines 204 to 216 in d66197a
It appears unnecessary for VariableLengthVector to do so. In many other cases, ITK does allow non-ITK exceptions to occur, so end-users have to deal with them anyway.
This pull request was triggered by a comment by Bradley (@blowekamp) at #5693 (comment) saying: