Skip to content

Commit

Permalink
STYLE: Remove unnecessary local output variables from PyVnl
Browse files Browse the repository at this point in the history
Let `_GetVnlVectorFromArray` and `_GetVnlMatrixFromArray` directly return the
constructed object. It is unnecessary to first store it in a local variable.
  • Loading branch information
N-Dekker authored and dzenanz committed Oct 17, 2024
1 parent d2a3f79 commit a870159
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Modules/Bridge/NumPy/include/itkPyVnl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ PyVnl<TElement>::_GetVnlVectorFromArray(PyObject * arr, PyObject * const shape)
return VectorType();
}
const auto * const data = static_cast<const DataType *>(buffer);
VectorType output(data, numberOfElements);

return output;
return VectorType(data, numberOfElements);
}

template <class TElement>
Expand Down Expand Up @@ -150,9 +148,7 @@ PyVnl<TElement>::_GetVnlMatrixFromArray(PyObject * arr, PyObject * const shape)
}

const auto * const data = static_cast<const DataType *>(buffer);
MatrixType output(data, size[0], size[1]);

return output;
return MatrixType(data, size[0], size[1]);
}


Expand Down

0 comments on commit a870159

Please sign in to comment.