Re: Strange Bitmapset manipulation in DiscreteKnapsack() - Mailing list pgsql-hackers

From David Rowley
Subject Re: Strange Bitmapset manipulation in DiscreteKnapsack()
Date
Msg-id CAApHDvrfxZkN6u-UddpTCb2C5X1MNmCa8f8N-671Vua+4wvouw@mail.gmail.com
Whole thread Raw
In response to Re: Strange Bitmapset manipulation in DiscreteKnapsack()  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-hackers
On Thu, 18 Jan 2024 at 16:24, David Rowley <dgrowleyml@gmail.com> wrote:
> On Thu, 18 Jan 2024 at 15:22, Richard Guo <guofenglinux@gmail.com> wrote:
> > Do you think we can use 'memcpy(a, b, BITMAPSET_SIZE(b->nwords))'
> > directly in the new bms_replace_members() instead of copying the
> > bitmapwords one by one, like:
> >
> > -   i = 0;
> > -   do
> > -   {
> > -       a->words[i] = b->words[i];
> > -   } while (++i < b->nwords);
> > -
> > -   a->nwords = b->nwords;
> > +   memcpy(a, b, BITMAPSET_SIZE(b->nwords));
> >
> > But I'm not sure if this is an improvement or not.
>
> I considered this earlier but felt it was going against the method
> used in other places in the file. However, on relooking I do see
> bms_copy() does a memcpy().

I feel it's not worth debating the memcpy thing any further, so I've
pushed the v2 patch.

Thanks for reviewing.

David



pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: ALTER ROLE documentation improvement
Next
From: Jeff Davis
Date:
Subject: Re: Built-in CTYPE provider