From 1ffd1ba7cb463abcd148abd608bebd2ab086ef76 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 17 Jul 2025 18:52:15 -0700 Subject: [PATCH] Replaces integerlength(n) implementation with call to fls(n) and makes it static --- inc/gcfinaldefs.h | 1 - src/gcfinal.c | 19 +++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/inc/gcfinaldefs.h b/inc/gcfinaldefs.h index 88945e3..fa6d0a0 100644 --- a/inc/gcfinaldefs.h +++ b/inc/gcfinaldefs.h @@ -2,7 +2,6 @@ #define GCFINALDEFS_H 1 #include "lispemul.h" /* for LispPTR, DLword */ void printarrayblock(LispPTR base); -int integerlength(unsigned int n); LispPTR findptrsbuffer(LispPTR ptr); LispPTR releasingvmempage(LispPTR ptr); LispPTR checkarrayblock(LispPTR base, LispPTR free, LispPTR onfreelist); diff --git a/src/gcfinal.c b/src/gcfinal.c index 568b99e..1d44336 100644 --- a/src/gcfinal.c +++ b/src/gcfinal.c @@ -43,6 +43,7 @@ /*************************************************************************/ #include // for printf +#include // for fls #include "address.h" // for HILOC #include "adr68k.h" // for NativeAligned4FromLAddr, LAddrFromNative #include "array.h" // for arrayblock, ARRAYBLOCKTRAILERCELLS, MAXBUCK... @@ -123,24 +124,10 @@ struct buf { #endif /* BIGVM */ #endif /* BYTESWAP */ -/************* The following procedure is common !! **************************/ - -int integerlength(unsigned int n) { - int cnt; - if (n <= 2) - return (n); - else { - cnt = 1; - do { - cnt++; - n = (n >> 1); - } while (n != 1); - return (cnt); - } +static int integerlength(unsigned int n) { + return (fls(n)); } -/************* The above procedure is common !! **************************/ - /************************************************************************/ /* */ /* f i n d p t r s b u f f e r */