svn commit: r347043 - head/sys/vm
Douglas William Moore
dougm at FreeBSD.org
Fri May 3 02:55:55 UTC 2019
Author: dougm
Date: Fri May 3 02:55:54 2019
New Revision: 347043
URL: https://svnweb.freebsd.org/changeset/base/347043
Log:
fls() should find the most significant bit of an int faster than a
linear search can, so use it to avoid a linear search in isqrt.
Approved by: kib (mentor), markj (mentor)
Differential Revision: https://reviews.freebsd.org/D20102
Modified:
head/sys/vm/vm_pageout.c
Modified: head/sys/vm/vm_pageout.c
==============================================================================
--- head/sys/vm/vm_pageout.c Fri May 3 02:51:33 2019 (r347042)
+++ head/sys/vm/vm_pageout.c Fri May 3 02:55:54 2019 (r347043)
@@ -928,9 +928,7 @@ isqrt(u_int num)
{
u_int bit, root, tmp;
- bit = 1u << ((NBBY * sizeof(u_int)) - 2);
- while (bit > num)
- bit >>= 2;
+ bit = num != 0 ? (1u << ((fls(num) - 1) & ~1)) : 0;
root = 0;
while (bit != 0) {
tmp = root + bit;
More information about the svn-src-all
mailing list