Re: Reduce the number of special cases to build contrib modules on windows
Andrew Dunstan <andrew@dunslane.net>
From: Andrew Dunstan <andrew@dunslane.net>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>,
David Rowley <dgrowleyml@gmail.com>
Cc: vignesh C <vignesh21@gmail.com>, Michael Paquier <michael@paquier.xyz>,
Andres Freund <andres@anarazel.de>,
PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2021-07-27T15:29:58Z
Lists: pgsql-hackers
On 7/27/21 11:01 AM, Alvaro Herrera wrote:
> On 2021-Jul-28, David Rowley wrote:
>
>> 0003: Is a tidy up patch to make the 'includes' field an array rather
>> than a string
> In this one, you can avoid turning one line into four with map,
>
> - $p->AddIncludeDir($pl_proj->{includes});
> + foreach my $inc (@{ $pl_proj->{includes} })
> + {
> + $p->AddIncludeDir($inc);
> + }
>
> Instead of that you can do something like this:
>
> + map { $p->AddIncludeDir($_); } @{$pl_proj->{includes}};
using map() for a side effect like this is generally frowned upon. See
<https://metacpan.org/pod/Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap>
do { $p->AddIncludeDir($_); } foreach @{$pl_proj->{includes}};
would be an ok one-liner.
>
>> 0004: Adds code to check for duplicate references and libraries before
>> adding new ones of the same name to the project.
> I think using the return value of grep as a boolean is confusing. It
> seems more legible to compare to 0. So instead of this:
>
> + if (! grep { $_ eq $ref} @{ $self->{references} })
> + {
> + push @{ $self->{references} }, $ref;
> + }
>
> use something like:
>
> + if (grep { $_ eq $ref} @{ $self->{references} } == 0)
>
But I believe that's a widely used idiom :-)
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Commits
-
Remove some special cases from MSVC build scripts
- 76ad24400d73 15.0 landed
-
Adjust MSVC build scripts to parse Makefiles for defines
- 245de48455da 15.0 landed
-
Don't duplicate references and libraries in MSVC scripts
- 15f16ec6511c 15.0 landed
-
Make the includes field an array in MSVC build scripts
- 33d74c5d00e4 15.0 landed
-
Use the AddFile function consistently in MSVC build scripts
- ed1884a2fede 15.0 landed
-
Remove seemingly unneeded include directory in MSVC scripts
- 4b763ff642e1 15.0 landed