Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Aug 2023 02:04:39 GMT
From:      Doug Moore <dougm@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: c2cbd7ffa71a - main - isa_common: find next bit faster
Message-ID:  <202308010204.37124dt1023439@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)));
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308010204.37124dt1023439>