Re: Reduce the number of special cases to build contrib modules on windows - Mailing list pgsql-hackers

From David Rowley
Subject Re: Reduce the number of special cases to build contrib modules on windows
Date
Msg-id CAApHDvrtGnN0SrhwEZoZRxxX9NNmk-TUb0ibmzMQRcvMfA6rYQ@mail.gmail.com
Whole thread Raw
In response to Re: Reduce the number of special cases to build contrib modules on windows  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-hackers
On Wed, 28 Jul 2021 at 04:01, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
>
> On 2021-Jul-27, Dagfinn Ilmari Mannsåker wrote:
>
> > Alvaro Herrera <alvherre@alvh.no-ip.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



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Reduce the number of special cases to build contrib modules on windows
Next
From: Michael Paquier
Date:
Subject: Re: truncating timestamps on arbitrary intervals