diff options
author | dominik <dominik@openttd.org> | 2004-08-23 10:59:03 +0000 |
---|---|---|
committer | dominik <dominik@openttd.org> | 2004-08-23 10:59:03 +0000 |
commit | a6f2257600b8818ceff54c4f2b7fee376f11cfe6 (patch) | |
tree | 03f736144e43a70ff9b3aaca01c983b5bc7d282c /misc.c | |
parent | cce45b44d8575bc60fe4b3c77c63987e40fc355a (diff) | |
download | openttd-a6f2257600b8818ceff54c4f2b7fee376f11cfe6.tar.xz |
(svn r117) Feature: Performance details window in company league menu (TrueLight)
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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; } |