From de73572b3d1668295faeb7c098aa1ecacc30d821 Mon Sep 17 00:00:00 2001 From: Martin Janiczek Date: Wed, 11 Oct 2023 17:22:43 +0200 Subject: [PATCH] AK: Fix doc comment for bit_scan_forward The original doc comment was mistakenly copy-pasted from count_leading_zeroes_safe, and incorrect. The function is doing something else: it's counting _trailing_ zeroes instead of _leading_ ones. --- AK/BuiltinWrappers.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/AK/BuiltinWrappers.h b/AK/BuiltinWrappers.h index a4a68a83e17..f24cea4cb31 100644 --- a/AK/BuiltinWrappers.h +++ b/AK/BuiltinWrappers.h @@ -128,9 +128,10 @@ inline constexpr int count_leading_zeroes_safe(IntType value) return count_leading_zeroes(value); } -// The function will return the number of leading zeroes in the type. If -// the given number is zero, this function will return the number of bits -// in the IntType. +// Returns one plus the index of the least significant 1-bit of x, or if x is +// zero, returns zero. (See __builtin_ffs.) +// +// For numbers above zero, bit_scan_forward(n) == count_trailing_zeroes(n) + 1. template inline constexpr int bit_scan_forward(IntType value) {