Re: Confusing comment in tidbitmap.c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Confusing comment in tidbitmap.c
Date: 2014-12-14 17:11:26
Message-ID: 20367.1418577086@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> The following comment above #define PAGES_PER_CHUNK in tibbitmap.c appears
> to be incorrect:

> "But we
> * also want PAGES_PER_CHUNK to be a power of 2 to avoid expensive integer
> * remainder operations. So, define it like this:"

> I don't quite follow this as it does nothing of the kind.
> Check tbm_page_is_lossy() where we do: bitno = pageno % PAGES_PER_CHUNK;

> Or am I missing something about the compiler optimizing that to: bitno =
> pageno & 255; ?

Exactly. Any C compiler ever written will do that.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2014-12-14 17:20:21 Re: proposal: plpgsql - Assert statement
Previous Message Tom Lane 2014-12-14 17:05:07 Re: Commitfest problems