Re: Change definitions of bitmap flags to bit-shifting style

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: James Coleman <jtc331(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Change definitions of bitmap flags to bit-shifting style
Date: 2020-12-06 17:16:31
Message-ID: 6dcd58bf-393d-f284-283c-ffb85767dd4c@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 12/6/20 11:44 AM, James Coleman wrote:
> On Sun, Dec 6, 2020 at 1:25 AM Michael Paquier <michael(at)paquier(dot)xyz
> <mailto:michael(at)paquier(dot)xyz>> wrote:
>
> On Sat, Dec 05, 2020 at 10:31:09PM -0300, Alvaro Herrera wrote:
> > The hexadecimal representation is more natural to me than
> bit-shifting,
> > so I would prefer to use that style too.  But maybe I'm trained
> to it
> > because of looking at t_infomask symbols constantly.
>
> If we are going to change all that, hexa style sounds good to me too.
> Would it be worth an addition to the docs, say in [1] to tell that
> this is a preferred style?
>
> [1]: https://www.postgresql.org/docs/devel/source-conventions.html
> <https://www.postgresql.org/docs/devel/source-conventions.html>?
> --
> Michael
>
>
>
> In my view the bit shifting approach makes it more obvious a single
> bit is being set, but on the other hand the hex approach makes it
> easier to compare in debugging. 
>
> I’m not really sure which to prefer, though I think I would have
> leaned slightly towards the former. 
>
>

Perhaps we should put one style or the other in a comment. I take Tom's
point, but after the number of bits shifted gets above some number I
have trouble remembering which bit it is, and while of course I can work
it out, it can be a very minor nuisance.

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2020-12-06 18:02:48 pg_upgrade test for binary compatibility of core data types
Previous Message James Coleman 2020-12-06 16:44:43 Re: Change definitions of bitmap flags to bit-shifting style