Re: move some bitmapset.c macros to bitmapset.h

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: move some bitmapset.c macros to bitmapset.h
Дата
Msg-id CAApHDvpyucADjv5D_vXUzxYBDsoohV5t-sjktYjugeDu3KSK-Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: move some bitmapset.c macros to bitmapset.h  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: move some bitmapset.c macros to bitmapset.h  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Tue, 6 Dec 2022 at 17:57, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> And RIGHTMOST_ONE is something that could be made public, but
> I think it belongs in pg_bitutils.h, perhaps with a different
> name.

Maybe there's a path of lesser resistance... There's been a bit of
work in pg_bitutils.h to define some of the bit manipulation functions
for size_t types which wrap the 32 or 64-bit version of the function
accordingly. Couldn't we just define one of those for
pg_rightmost_one_pos and then use a size_t as the bitmap word type?

Then you'd end up with something like:

for (idx = 0; idx < 128 / (sizeof(size_t) * 8); idx++)
 if (isset[idx] != ~((size_t) 0))
    break;
slotpos = idx * (sizeof(size_t) * 8) + pg_rightmost_one_pos_size_t(~isset[idx]);

no need to export anything from bitmapset.c to do it like that.

I've not looked at the code in question to know how often that form
would be needed. Maybe it would need a set of inlined functions
similar to above in the same file this is being used in to save on
repeating too often.

David



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Vik Fearing
Дата:
Сообщение: Re: ANY_VALUE aggregate
Следующее
От: Tom Lane
Дата:
Сообщение: Re: move some bitmapset.c macros to bitmapset.h