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

From Dag Lem
Subject Re: [PATCH] Add function to_oct
Date
Msg-id 167170369754.1121.7881078512513671914.pgcf@coridan.postgresql.org
Whole thread Raw
In response to Re: [PATCH] Add function to_oct  (Ian Lawrence Barwick <barwick@gmail.com>)
Responses Re: [PATCH] Add function to_oct
List pgsql-hackers
The following review has been posted through the commitfest application:
make installcheck-world:  not tested
Implements feature:       not tested
Spec compliant:           not tested
Documentation:            not tested

This is a mini-review of to_oct :-)

The function seems useful to me, and is obviously correct.

I don't know whether optimization at such a low level is considered in PostgreSQL, but here goes.

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
exhaustedby a 32 bit integer (the maximum octal number being 37777777777).
 


Best regards

Dag Lem

The new status of this patch is: Waiting on Author

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Perform streaming logical transactions by background workers and parallel apply
Next
From: John Naylor
Date:
Subject: Re: [PoC] Improve dead tuple storage for lazy vacuum