COMP: Replace raw new[] with std::vector in CellInterfaceTest#5996
Merged
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:mainfrom Apr 1, 2026
Merged
Conversation
5 tasks
Contributor
|
| Filename | Overview |
|---|---|
| Modules/Core/Mesh/test/itkCellInterfaceTest.cxx | Clean replacement of raw new[]/delete[] with std::vector + std::iota; adds required <numeric> and <vector> includes. Logic and pointer usage are correct. |
| Modules/Numerics/FEM/include/itkFEMLinearSystemWrapperDenseVNL.h | Modernises raw-pointer members to std::unique_ptr; destructor simplified to = default. Missing #include <memory> for the newly introduced std::unique_ptr usage. |
| Modules/Numerics/FEM/src/itkFEMLinearSystemWrapperDenseVNL.cxx | All new/delete replaced with make_unique/reset; destructor body removed; std::swap used for pointer-level swaps. Semantics are preserved and the virtual-call-in-destructor anti-pattern is eliminated. |
Class Diagram
%%{init: {'theme': 'neutral'}}%%
classDiagram
class LinearSystemWrapperDenseVNL {
-unique_ptr~MatrixHolder~ m_Matrices
-unique_ptr~vector~unique_ptr~vnl_vector~Float~~~~ m_Vectors
-unique_ptr~vector~unique_ptr~vnl_vector~Float~~~~ m_Solutions
+InitializeMatrix(idx)
+DestroyMatrix(idx)
+InitializeVector(idx)
+DestroyVector(idx)
+InitializeSolution(idx)
+DestroySolution(idx)
+SwapMatrices(i,j)
+SwapVectors(i,j)
+SwapSolutions(i,j)
+CopySolution2Vector(si,vi)
+CopyVector2Solution(vi,si)
+Solve()
+~LinearSystemWrapperDenseVNL() = default
}
class MatrixHolder {
<<type alias>>
vector~unique_ptr~vnl_matrix~Float~~~
}
LinearSystemWrapperDenseVNL --> MatrixHolder : owns via unique_ptr
LinearSystemWrapperDenseVNL --|> LinearSystemWrapper
Reviews (1): Last reviewed commit: "COMP: Replace raw new[] with std::vector..." | Re-trigger Greptile
- Replace PointIdentifier array allocation with std::vector - Use .data() method for passing to SetPointIds Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
780311e to
6ff3e29
Compare
dzenanz
approved these changes
Apr 1, 2026
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.
Summary
Replace raw
new[]/delete[]array allocation withstd::vectorinitkCellInterfaceTest.cxx, following C++ Core Guidelines R.11 (avoid callingnew/delete) and ES.27 (usestd::arrayorstack_arrayfor arrays on the stack).new PointIdentifier[N]withstd::vector<PointIdentifier>(N)std::iotato initialize the sequence, replacing the manual loop.data()and.data() + offsetfor the pointer-basedSetPointIdscallsdelete[] pointIds— memory managed automatically bystd::vector<numeric>and<vector>includesTest plan
itkCellInterfaceTestpasses (ctest -R itkCellInterface)🤖 Generated with Claude Code