From 3188546a47a4c84a4212a8cb1766be6a7c7cd9fd Mon Sep 17 00:00:00 2001 From: Ignat Loskutov Date: Fri, 24 Oct 2025 18:58:54 +0200 Subject: [PATCH] hiscoa-compress: faster msb calculation --- src/hiscoa-compress.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/hiscoa-compress.c b/src/hiscoa-compress.c index 4ed1f22..f6a5a6c 100644 --- a/src/hiscoa-compress.c +++ b/src/hiscoa-compress.c @@ -89,13 +89,9 @@ static void swap(unsigned *a, unsigned *b) static unsigned find_msb(unsigned val) { - /* FIXME do this faster */ - unsigned nbits; if (val == 0) return 0; - for (nbits = 8 * sizeof(val) - 1; val < (1u << nbits); --nbits) - ; - return nbits + 1; + return 8 * sizeof(val) - __builtin_clz(val); } static bool try_write_longrepeat(struct state *state)