From a434e3f71829f23cd748a1694bc64455aecceabd Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 9 Oct 2024 22:21:54 +0200 Subject: [PATCH] STYLE: Remove local `memoryView` variables from "Bridge/NumPy" Directly return `PyMemoryView_FromBuffer(&pyBuffer)` instead. --- Modules/Bridge/NumPy/include/itkPyBuffer.hxx | 4 +--- Modules/Bridge/NumPy/include/itkPyVectorContainer.hxx | 4 +--- Modules/Bridge/NumPy/include/itkPyVnl.hxx | 8 ++------ 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Modules/Bridge/NumPy/include/itkPyBuffer.hxx b/Modules/Bridge/NumPy/include/itkPyBuffer.hxx index a9b9524b6b2..b4354ef8f72 100644 --- a/Modules/Bridge/NumPy/include/itkPyBuffer.hxx +++ b/Modules/Bridge/NumPy/include/itkPyBuffer.hxx @@ -58,9 +58,7 @@ PyBuffer::_GetArrayViewFromImage(ImageType * image) len *= sizeof(ComponentType); PyBuffer_FillInfo(&pyBuffer, nullptr, itkImageBuffer, len, 0, PyBUF_CONTIG); - PyObject * const memoryView = PyMemoryView_FromBuffer(&pyBuffer); - - return memoryView; + return PyMemoryView_FromBuffer(&pyBuffer); } template diff --git a/Modules/Bridge/NumPy/include/itkPyVectorContainer.hxx b/Modules/Bridge/NumPy/include/itkPyVectorContainer.hxx index d432ece80db..2ec4d54a3ce 100644 --- a/Modules/Bridge/NumPy/include/itkPyVectorContainer.hxx +++ b/Modules/Bridge/NumPy/include/itkPyVectorContainer.hxx @@ -44,9 +44,7 @@ PyVectorContainer::_array_view_from_vector_contain len *= sizeof(DataType); PyBuffer_FillInfo(&pyBuffer, nullptr, vectorBuffer, len, 0, PyBUF_CONTIG); - PyObject * const memoryView = PyMemoryView_FromBuffer(&pyBuffer); - - return memoryView; + return PyMemoryView_FromBuffer(&pyBuffer); } template diff --git a/Modules/Bridge/NumPy/include/itkPyVnl.hxx b/Modules/Bridge/NumPy/include/itkPyVnl.hxx index b62124f306f..7f4e417b549 100644 --- a/Modules/Bridge/NumPy/include/itkPyVnl.hxx +++ b/Modules/Bridge/NumPy/include/itkPyVnl.hxx @@ -44,9 +44,7 @@ PyVnl::_GetArrayViewFromVnlVector(VectorType * vector) len *= sizeof(DataType); PyBuffer_FillInfo(&pyBuffer, nullptr, vectorBuffer, len, 0, PyBUF_CONTIG); - PyObject * const memoryView = PyMemoryView_FromBuffer(&pyBuffer); - - return memoryView; + return PyMemoryView_FromBuffer(&pyBuffer); } template @@ -103,9 +101,7 @@ PyVnl::_GetArrayViewFromVnlMatrix(MatrixType * matrix) len *= sizeof(DataType); PyBuffer_FillInfo(&pyBuffer, nullptr, matrixBuffer, len, 0, PyBUF_CONTIG); - PyObject * const memoryView = PyMemoryView_FromBuffer(&pyBuffer); - - return memoryView; + return PyMemoryView_FromBuffer(&pyBuffer); } template