From a6f2257600b8818ceff54c4f2b7fee376f11cfe6 Mon Sep 17 00:00:00 2001 From: dominik Date: Mon, 23 Aug 2004 10:59:03 +0000 Subject: (svn r117) Feature: Performance details window in company league menu (TrueLight) --- misc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'misc.c') diff --git a/misc.c b/misc.c index 06e790019..5f86d8445 100644 --- a/misc.c +++ b/misc.c @@ -601,11 +601,18 @@ void IncreaseDate() /* XXX: check if year 2050 was reached */ } -int FindFirstBit(uint32 x) +int FindFirstBit(uint32 value) { - int i = 0; - assert(x != 0); - for(;!(x&1);i++,x>>=1); + // This is much faster then the one that was before here. + // Created by Darkvater.. blame him if it is wrong ;) + // Btw, the macro FINDFIRSTBIT is better to use when your value is + // not more then 128. + byte i = 0; + if (value & 0xffff0000) { value >>= 16; i += 16; } + if (value & 0x0000ff00) { value >>= 8; i += 8; } + if (value & 0x000000f0) { value >>= 4; i += 4; } + if (value & 0x0000000c) { value >>= 2; i += 2; } + if (value & 0x00000002) { i += 1; } return i; } -- cgit v1.2.3-54-g00ecf