# HG changeset patch # User Benjamin Golinvaux # Date 1586527934 -7200 # Node ID b1e6bef869558bf774c7d1bd6f4fd0daeed5dd1e # Parent eac254fb67914a3e05191463be50474779543ce6 Tentative loop optimization in CopyPixelDataAndComputeDistribution diff -r eac254fb6791 -r b1e6bef86955 Framework/Loaders/OrthancMultiframeVolumeLoader.cpp --- 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(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(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; } } }