Signed-off-by: Paul Gofman <pgofman@xxxxxxxxxxxxxxx> --- v2: - simplify log2_int implementation. util_math.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/util_math.h b/util_math.h index e2fa95f5..32297349 100644 --- a/util_math.h +++ b/util_math.h @@ -33,16 +33,11 @@ static inline unsigned log2_int(unsigned x) { - unsigned l; + unsigned l = 0; - if (x < 2) { - return 0; - } - for (l = 2; ; l++) { - if ((unsigned)(1 << l) > x) { - return l - 1; - } - } - return 0; + while (x >>= 1) + ++l; + + return l; } #endif /*_UTIL_MATH_H_*/ -- 2.28.0 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel