Re: [PATCH] Add function to_oct

From: Eric Radman <ericshane(at)eradman(dot)com>
To: Dag Lem <dag(at)nimrod(dot)no>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Add function to_oct
Date: 2022-12-22 17:41:24
Message-ID: Y6SWxEM92Pbqs0l/@vm3.eradman.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
add-function-to_oct-v2.patch text/plain 3.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikita Malakhov 2022-12-22 18:07:31 Re: [PATCH] Infinite loop while acquiring new TOAST Oid
Previous Message Ranier Vilela 2022-12-22 17:29:11 Re: Small miscellaneus fixes (Part II)