Re: [PATCH] Add function to_oct - Mailing list pgsql-hackers

From Eric Radman
Subject Re: [PATCH] Add function to_oct
Date
Msg-id Y6SWxEM92Pbqs0l/@vm3.eradman.com
Whole thread Raw
In response to Re: [PATCH] Add function to_oct  (Dag Lem <dag@nimrod.no>)
Responses Re: [PATCH] Add function to_oct
List pgsql-hackers
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

Attachment

pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Re: Small miscellaneus fixes (Part II)
Next
From: Nikita Malakhov
Date:
Subject: Re: [PATCH] Infinite loop while acquiring new TOAST Oid