Optimize check (not like it is called much, just ffs; not tested)
authorunc0rr
Fri, 04 Mar 2011 11:30:53 +0300
changeset 4981 0c60ade27a0a
parent 4980 3b40c80c0fe3
child 4982 3572eaf14340
Optimize check (not like it is called much, just ffs; not tested)
hedgewars/uUtils.pas
--- a/hedgewars/uUtils.pas	Thu Mar 03 22:15:42 2011 +0300
+++ b/hedgewars/uUtils.pas	Fri Mar 04 11:30:53 2011 +0300
@@ -185,9 +185,7 @@
 
 function isPowerOf2(i: Longword): boolean;
 begin
-if i = 0 then exit(true);
-while not odd(i) do i:= i shr 1;
-isPowerOf2:= (i = 1)
+isPowerOf2:= (i and (i - 1)) = 0
 end;
 
 function toPowerOf2(i: Longword): Longword;