From: Max Maischein Date: Thu, 3 Oct 2013 16:48:27 +0000 (+0200) Subject: Elide use of `grep` X-Git-Tag: upstream/5.20.0~1596^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cefd15c28021ef0818c51846c60d89cf62b32fc7;p=platform%2Fupstream%2Fperl.git Elide use of `grep` The new approach uses more memory as it reads the whole 11 MB CPAN packages file into memory. Also, it makes less use of parallel multiprocessing now available on many machines. --- diff --git a/Porting/sync-with-cpan b/Porting/sync-with-cpan index a0a26d6..795fe1b 100755 --- a/Porting/sync-with-cpan +++ b/Porting/sync-with-cpan @@ -243,9 +243,9 @@ unless ($tarball) { } or system wget => $package_url, '-qO', $package_file; } - my $new_line = `grep '^$cpan_mod ' $package_file` + open my $fh, '<', $package_file; + (my $new_line) = grep {/^$cpan_mod/} <$fh> # Yes, this needs a lot of memory or die "Cannot find $cpan_mod on CPAN\n"; - chomp $new_line; (undef, $new_version, my $new_path) = split ' ', $new_line; if (defined $version) { $new_path =~ s/-$new_version\./-$version\./; @@ -476,7 +476,9 @@ my @tests = glob 'porting/*.t'; chomp @tests; my @failed; foreach my $t (@tests) { - my @not = `./perl -I../lib -I.. $t | grep ^not | grep -v "# TODO"`; + my @not = grep {!/# TODO/ } + grep { /^not/ } + `${exe_dir}perl -I../lib -I.. $t`; print @not ? '!' : '.'; push @failed => $t if @not; }