From 84b7f434f49d4e336774c5e9c5ce01ef97ae5537 Mon Sep 17 00:00:00 2001
From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr>
Date: Fri, 30 Sep 2016 15:44:37 +0200
Subject: [PATCH] ENH: move var to loop scope and add const

---
 .../include/otbNeighborhoodMajorityVotingImageFilter.txx  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx
index 2a5cad153a..1b656f1420 100644
--- a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx
+++ b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx
@@ -109,9 +109,9 @@ unsigned int NeighborhoodMajorityVotingImageFilter<TInputImage,
 {  
   std::map<PixelType, unsigned int> histoNeigh;
   PixelType centerPixel = nit.GetCenterPixel();
-  unsigned int i;
-  KernelIteratorType kernel_it;
-  for (i = 0, kernel_it = kernelBegin; kernel_it < kernelEnd; ++kernel_it, ++i)
+  unsigned int i = 0; 
+  for (KernelIteratorType kernel_it = kernelBegin; 
+       kernel_it < kernelEnd; ++kernel_it, ++i)
     {
     // if structuring element is positive, use the pixel under that element
     // in the image
@@ -125,7 +125,7 @@ unsigned int NeighborhoodMajorityVotingImageFilter<TInputImage,
       }
     }
   std::copy(histoNeigh.begin(), histoNeigh.end(), std::back_inserter(histoNeighVec));
-  typename std::vector<std::pair<PixelType, unsigned int> >::iterator histoIt = histoNeighVec.begin();
+  const typename std::vector<std::pair<PixelType, unsigned int> >::iterator histoIt = histoNeighVec.begin();
   std::nth_element(histoNeighVec.begin(), histoIt+1,
                    histoNeighVec.end(), CompareHistoFequencies());
   return histoNeigh[centerPixel];
-- 
GitLab