From 6e97bf05c0af7e4c398af5d6f7fc8adee12ae3a9 Mon Sep 17 00:00:00 2001
From: ctraizet <cedric.traizet@c-s.fr>
Date: Wed, 6 Feb 2019 16:14:26 +0100
Subject: [PATCH] ENH: factorize the GetPixel method outside of the loop

---
 Modules/Core/Functor/test/otbFunctorImageFilter.cxx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Modules/Core/Functor/test/otbFunctorImageFilter.cxx b/Modules/Core/Functor/test/otbFunctorImageFilter.cxx
index f24ab33a06..bf418e2a0b 100644
--- a/Modules/Core/Functor/test/otbFunctorImageFilter.cxx
+++ b/Modules/Core/Functor/test/otbFunctorImageFilter.cxx
@@ -285,9 +285,10 @@ template<typename T> struct MaxInEachChannel
 
     for (auto idx = 0u; idx < in.Size(); idx++)
       {
+      auto pixel = in.GetPixel(idx);
       for(auto band = 0u; band < out.Size();++band)
         {
-        if(in.GetPixel(idx)[band] < out[band])
+        if(pixel[band] < out[band])
           out[band] = in.GetPixel(idx)[band];
         }
       }
-- 
GitLab