Author: amunger
Date: Fri May 5 19:10:59 2006
New Revision: 21801
URL:
http://svn.reactos.ru/svn/reactos?rev=21801&view=rev
Log:
"More efficient" IsPowerOf2 from Myria (myriachan at cox dot net).
Modified:
trunk/reactos/ntoskrnl/mm/pe.c
Modified: trunk/reactos/ntoskrnl/mm/pe.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/mm/pe.c?rev=21801&…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/pe.c (original)
+++ trunk/reactos/ntoskrnl/mm/pe.c Fri May 5 19:10:59 2006
@@ -103,12 +103,8 @@
static __inline BOOLEAN IsPowerOf2(IN ULONG Number)
{
if(Number == 0)
- return FALSE;
-
- while((Number % 2) == 0)
- Number /= 2;
-
- return Number == 1;
+ return FALSE;
+ return (Number & (Number - 1)) == 0;
}
static __inline ULONG ModPow2(IN ULONG Address, IN ULONG Alignment)