Re: Reduce the number of special cases to build contrib modules on windows

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Reduce the number of special cases to build contrib modules on windows
Date: 2021-07-28 04:13:35
Message-ID: CAApHDvrtGnN0SrhwEZoZRxxX9NNmk-TUb0ibmzMQRcvMfA6rYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 28 Jul 2021 at 04:01, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> On 2021-Jul-27, Dagfinn Ilmari Mannsåker wrote:
>
> > Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
>
> > > + if (grep { $_ eq $ref} @{ $self->{references} } == 0)
> >
> > I disagree. Using grep in boolean context is perfectly idiomatic perl.
> > What would be more idiomatic is List::Util::any, but that's not availble
> > without upgrading List::Util from CPAN on Perls older than 5.20, so we
> > can't use that.
>
> I was wondering if instead of grepping the whole list for each addition
> it would make sense to push always, and do a unique-ification step at
> the end.

I see [1] has some thoughts on this, I don't think performance will
matter much here though. I think the order of the final array is
likely more important. I didn't test, but I imagine using one of
those hash solutions might end up having the array elements in some
hashtable like order.

I'm not quite sure if I can tell here if it's ok to leave the grep
as-is or if I should be changing it to:

if (grep { $_ eq $ref} @{ $self->{references} } == 0)

David

[1] https://www.oreilly.com/library/view/perl-cookbook/1565922433/ch04s07.html

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-07-28 04:14:58 Re: truncating timestamps on arbitrary intervals
Previous Message David Rowley 2021-07-28 04:07:39 Re: Reduce the number of special cases to build contrib modules on windows