aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-10-13 08:58:48 -0700
committerChris Robinson <[email protected]>2012-10-13 08:58:48 -0700
commite60281c9277c46822f2f6b844c4910c3e1e55298 (patch)
tree713fd757ab3a331649bfaba0321988a1305425d3 /OpenAL32/Include
parent01136ecd5170c7675e576f05635fc9c20d3fc113 (diff)
Don't use a loop to determine the next power of 2
Diffstat (limited to 'OpenAL32/Include')
-rw-r--r--OpenAL32/Include/alMain.h16
1 files 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