From e60281c9277c46822f2f6b844c4910c3e1e55298 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 13 Oct 2012 08:58:48 -0700 Subject: Don't use a loop to determine the next power of 2 --- OpenAL32/Include/alMain.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index b5c3493c..fec9856f 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -393,18 +393,16 @@ struct Hrtf; // Find the next power-of-2 for non-power-of-2 numbers. static __inline ALuint NextPowerOf2(ALuint value) { - ALuint powerOf2 = 1; - - if(value) + if(value > 0) { value--; - while(value) - { - value >>= 1; - powerOf2 <<= 1; - } + value |= value>>1; + value |= value>>2; + value |= value>>4; + value |= value>>8; + value |= value>>16; } - return powerOf2; + return value+1; } /* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero -- cgit v1.2.3