changeset 1349:b1e6bef86955 broker

Tentative loop optimization in CopyPixelDataAndComputeDistribution
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 10 Apr 2020 16:12:14 +0200
parents eac254fb6791
children c53a4667f895
files Framework/Loaders/OrthancMultiframeVolumeLoader.cpp
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Loaders/OrthancMultiframeVolumeLoader.cpp	Tue Apr 07 14:31:28 2020 +0200
+++ b/Framework/Loaders/OrthancMultiframeVolumeLoader.cpp	Fri Apr 10 16:12:14 2020 +0200
@@ -313,21 +313,23 @@
         assert(writer.GetAccessor().GetWidth() == width &&
           writer.GetAccessor().GetHeight() == height);
 
+        T* targetAddr0 = reinterpret_cast<T*>(writer.GetAccessor().GetRow(0));
+        unsigned int pitch = writer.GetAccessor().GetPitch();
+        T* targetAddr = targetAddr0;
+        assert(sizeof(T) == Orthanc::GetBytesPerPixel(target.GetFormat()));
+
         for (unsigned int y = 0; y < height; y++)
         {
-          assert(sizeof(T) == Orthanc::GetBytesPerPixel(target.GetFormat()));
-
-          T* target = reinterpret_cast<T*>(writer.GetAccessor().GetRow(y));
-
           for (unsigned int x = 0; x < width; x++)
           {
-            CopyPixel(*target, source);
+            CopyPixel(*targetAddr, source);
 
-            distribution[*target] += 1;
+            distribution[*targetAddr] += 1;
 
-            target++;
+            targetAddr++;
             source += bpp;
           }
+          targetAddr += pitch;
         }
       }
     }