git: c2cbd7ffa71a - main - isa_common: find next bit faster

From: Doug Moore <dougm_at_FreeBSD.org>
Date: Tue, 01 Aug 2023 02:04:39 UTC
The branch main has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=c2cbd7ffa71a4009e4cc38c04c726ea562b11361

commit c2cbd7ffa71a4009e4cc38c04c726ea562b11361
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2023-08-01 02:02:56 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2023-08-01 02:02:56 +0000

    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
---
 sys/isa/isa_common.c | 7 +------
 1 file changed, 1 insertion(+), 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)));
 }
 
 /*