Optimize bitscanforward using intrinsic function

This commit is contained in:
Daniël Heres 2015-10-20 18:10:05 +02:00
parent 3f99209219
commit d531243c98
1 changed files with 5 additions and 0 deletions

View File

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