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

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Change definitions of bitmap flags to bit-shifting style
Date: 2020-12-06 05:22:27
Message-ID: 0e8cde37d304ebbae582455aad145f42757f1f89.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 2020-12-05 at 13:03 -0500, Tom Lane wrote:
> Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> writes:
>
> > The attached patch changes definitions like
> > #define FOO 0x01
> > #define BAR 0x02
> > to
> > #define FOO (1 << 0)
> > #define BAR (1 << 1)
> > etc.
>
> > Both styles are currently in use, but the latter style seems more
> > readable and easier to update.
>
> FWIW, personally I'd vote for doing the exact opposite. When you are
> debugging and examining the contents of a bitmask variable, it's easier to
> correlate a value like "0x03" with definitions made in the former style.
> Or at least I think so; maybe others see it differently.

+1

Laurenz Albe

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-12-06 06:25:06 Re: Change definitions of bitmap flags to bit-shifting style
Previous Message Andy Fan 2020-12-06 03:38:55 Re: [PATCH] Keeps tracking the uniqueness with UniqueKey