Skip to content

Commit e008f0a

Browse files
committed
STYLE: Use std::array instead of std::vector for local variables in IO
Declared those variables const when possible.
1 parent 20a85b8 commit e008f0a

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Modules/IO/JPEG/src/itkJPEGImageIO.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "itksys/SystemTools.hxx"
2121

2222
#include "itk_jpeg.h"
23+
24+
#include <array>
2325
#include <csetjmp>
2426

2527
#define JPEGIO_JPEG_MESSAGES 1
@@ -542,13 +544,11 @@ JPEGImageIO::WriteSlice(const std::string & fileName, const void * const buffer)
542544
{
543545
// store the spacing information as pixels per inch or cm, depending on which option
544546
// retains as much precision as possible
545-
std::vector<UINT16> densityPerInch(2);
546-
densityPerInch[0] = static_cast<UINT16>(25.4 / m_Spacing[0] + 0.5);
547-
densityPerInch[1] = static_cast<UINT16>(25.4 / m_Spacing[1] + 0.5);
547+
const std::array<UINT16, 2> densityPerInch{ static_cast<UINT16>(25.4 / m_Spacing[0] + 0.5),
548+
static_cast<UINT16>(25.4 / m_Spacing[1] + 0.5) };
548549

549-
std::vector<UINT16> densityPerCm(2);
550-
densityPerCm[0] = static_cast<UINT16>(10.0 / m_Spacing[0] + 0.5);
551-
densityPerCm[1] = static_cast<UINT16>(10.0 / m_Spacing[1] + 0.5);
550+
const std::array<UINT16, 2> densityPerCm{ static_cast<UINT16>(10.0 / m_Spacing[0] + 0.5),
551+
static_cast<UINT16>(10.0 / m_Spacing[1] + 0.5) };
552552

553553
if (itk::Math::abs(25.4 / m_Spacing[0] - densityPerInch[0]) +
554554
itk::Math::abs(25.4 / m_Spacing[1] - densityPerInch[1]) <=

Modules/IO/MINC/src/itkMINCImageIO.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "itk_minc2.h"
2929

30+
#include <array>
3031
#include <memory> // For unique_ptr.
3132

3233

@@ -481,7 +482,7 @@ MINCImageIO::ReadImageInformation()
481482

482483
double _sep = NAN;
483484
miget_dimension_separation(m_MINCPImpl->m_MincApparentDims[usableDimensions], MI_ORDER_APPARENT, &_sep);
484-
std::vector<double> _dir(3);
485+
std::array<double, 3> _dir{};
485486
miget_dimension_cosines(m_MINCPImpl->m_MincApparentDims[usableDimensions], &_dir[0]);
486487
double _start = NAN;
487488
miget_dimension_start(m_MINCPImpl->m_MincApparentDims[usableDimensions], MI_ORDER_APPARENT, &_start);

0 commit comments

Comments
 (0)