From 393f3279f6d11e06ded09c9e51bfb0d9d905a09e Mon Sep 17 00:00:00 2001 From: ferralverrall Date: Fri, 10 Aug 2018 08:30:50 -0700 Subject: [PATCH] Update RadixSort.cpp Move if check out of inner while loop --- src/nvcore/RadixSort.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/nvcore/RadixSort.cpp b/src/nvcore/RadixSort.cpp index 3f44620..d9e4384 100644 --- a/src/nvcore/RadixSort.cpp +++ b/src/nvcore/RadixSort.cpp @@ -1,4 +1,4 @@ -// This code is in the public domain -- Ignacio Castaño +// This code is in the public domain -- Ignacio Castaño #include "RadixSort.h" @@ -44,11 +44,23 @@ void createHistograms(const T * buffer, uint count, uint * histogram) // Build histograms. const uint8 * p = (const uint8 *)buffer; // @@ Does this break aliasing rules? const uint8 * pe = p + count * sizeof(T); - - while (p != pe) { - h[0][*p++]++, h[1][*p++]++, h[2][*p++]++, h[3][*p++]++; - if (bucketCount == 8) h[4][*p++]++, h[5][*p++]++, h[6][*p++]++, h[7][*p++]++; + + if (bucketCount != 8) + { + while (p != pe) + { + h[0][*p++]++, h[1][*p++]++, h[2][*p++]++, h[3][*p++]++; + } + } + else + { + while (p != pe) + { + h[0][*p++]++, h[1][*p++]++, h[2][*p++]++, h[3][*p++]++; + h[4][*p++]++, h[5][*p++]++, h[6][*p++]++, h[7][*p++]++; + } } + } /*