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; _______________________________________________ [email protected] mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "[email protected]"
