diff options
author | Doug Moore <dougm@FreeBSD.org> | 2023-08-01 02:02:56 +0000 |
---|---|---|
committer | Doug Moore <dougm@FreeBSD.org> | 2023-08-01 02:02:56 +0000 |
commit | c2cbd7ffa71a4009e4cc38c04c726ea562b11361 (patch) | |
tree | fbf6a243a00ecd9dbeee047986da76a35f903790 | |
parent | fa3cf6cdc68cb6d6f2c440f2653258d68eae1015 (diff) | |
download | src-c2cbd7ffa71a4009e4cc38c04c726ea562b11361.tar.gz src-c2cbd7ffa71a4009e4cc38c04c726ea562b11361.zip |
isa_common: find next bit faster
Since ffs is no longer implemented with a linear search, find_next_bit
can work in constant time, with masking.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D41251
-rw-r--r-- | sys/isa/isa_common.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/sys/isa/isa_common.c b/sys/isa/isa_common.c index ca7fd15442b2..994288886cea 100644 --- a/sys/isa/isa_common.c +++ b/sys/isa/isa_common.c @@ -275,12 +275,7 @@ find_first_bit(uint32_t mask) static int find_next_bit(uint32_t mask, int bit) { - bit++; - while (bit < 32 && !(mask & (1 << bit))) - bit++; - if (bit != 32) - return (bit); - return (-1); + return (find_first_bit(mask & (-2 << bit))); } /* |