diff OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp @ 4278:9279de56a405

avoid multiple calls to GetWidth() and GetHeight() on pixel loops
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 03 Nov 2020 20:05:55 +0100
parents 0034f855c023
children 3b70a2e6a06c
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp	Tue Nov 03 18:45:32 2020 +0100
+++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp	Tue Nov 03 20:05:55 2020 +0100
@@ -1363,7 +1363,10 @@
     Uint8* target = NULL;
     pixels->createUint8Array(accessor.GetHeight() * pitch, target);
 
-    for (unsigned int y = 0; y < accessor.GetHeight(); y++)
+    const unsigned int height = accessor.GetHeight();
+    const unsigned int width = accessor.GetWidth();
+
+    for (unsigned int y = 0; y < height; y++)
     {
       switch (accessor.GetFormat())
       {
@@ -1381,7 +1384,7 @@
         {
           // The alpha channel is not supported by the DICOM standard
           const Uint8* source = reinterpret_cast<const Uint8*>(accessor.GetConstRow(y));
-          for (unsigned int x = 0; x < accessor.GetWidth(); x++, target += 3, source += 4)
+          for (unsigned int x = 0; x < width; x++, target += 3, source += 4)
           {
             target[0] = source[0];
             target[1] = source[1];