Re: [COMMITTERS] pgsql: Clean up Perl code according toperlcritic

Поиск
Список
Период
Сортировка
Искать

Re: [COMMITTERS] pgsql: Clean up Perl code according toperlcritic

От:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Дата:
On 3/28/17 05:23, Dagfinn Ilmari Mannsåker wrote:
> I suggest splitting the substitution and filtering part into separate
> map and grep calls, for clarity.  The substituion is crying out for the
> /r regex modifier to avoid the local variable, but that's only available
> since perl 5.14.
> 
> diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
> index d9367f8..cf93a60 100644
> --- a/src/tools/msvc/vcregress.pl
> +++ b/src/tools/msvc/vcregress.pl
> @@ -520,11 +520,9 @@ sub fetchRegressOpts
>  		# Substitute known Makefile variables, then ignore options that retain
>  		# an unhandled variable reference.  Ignore anything that isn't an
>  		# option starting with "--".
> -		@opts = grep {
> -			my $x = $_;
> -			$x =~ s/\Q$(top_builddir)\E/\"$topdir\"/;
> -			$x !~ /\$\(/ && $x =~ /^--/
> -		} split(/\s+/, $1);
> +		@opts = grep { !/\$\(/ && /^--/ }
> +			map { (my $x = $_) =~ s/\Q$(top_builddir)\E/\"$topdir\"/; $x;}
> +			split(/\s+/, $1);
>  	}
>  	if ($m =~ /^\s*ENCODING\s*=\s*(\S+)/m)
>  	{

Committed that way.


-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


FAQ