1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Merge pull request #2093 from Dandandan/optimizebitscan

Optimize bitscanforward using intrinsic function
This commit is contained in:
Ted John
2015-10-20 17:32:39 +01:00

View File

@@ -143,11 +143,16 @@ int bitscanforward(int source)
{ {
int i; int i;
#if _MSC_VER >= 1400 // Visual Studio 2005
_BitScanForward(&i, source);
return i;
#else
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
if (source & (1 << i)) if (source & (1 << i))
return i; return i;
return -1; return -1;
#endif
} }
int bitcount(int source) int bitcount(int source)