On Thu, Dec 22, 2022 at 10:08:17AM +0000, Dag Lem wrote:
>
> The calculation of quotient and remainder can be replaced by less costly masking and shifting.
>
> Defining
>
> #define OCT_DIGIT_BITS 3
> #define OCT_DIGIT_BITMASK 0x7
>
> the content of the loop can be replaced by
>
> *--ptr = digits[value & OCT_DIGIT_BITMASK];
> value >>= OCT_DIGIT_BITS;
>
> Also, the check for ptr > buf in the while loop can be removed. The
> check is superfluous, since buf cannot possibly be exhausted by a 32
> bit integer (the maximum octal number being 37777777777).
I integrated these suggestions in the attached -v2 patch and tested
range of values manually.
Also picked an OID > 8000 as suggested by unused_oids.
..Eric