From: Graham Knop Date: Tue, 27 Sep 2016 01:19:13 +0000 (-0400) Subject: fix and speed up directory scan X-Git-Tag: v0.003000~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f39746fb12a35c6a550b4b909ceea5d951cbf262;p=p5sagit%2FDistar.git fix and speed up directory scan --- diff --git a/helpers/bump-version b/helpers/bump-version index 5373656..7a4b6bc 100755 --- a/helpers/bump-version +++ b/helpers/bump-version @@ -18,12 +18,22 @@ my ($new_decimal, $new_vstring) = bump_version($old_version, $bump); warn "Bumping $old_version -> $new_decimal\n"; -my $file_match = qr{^(?: +my $file_match = qr{ Makefile\.PL |lib[/\\].*\.(?:pod|pm) |bin[/\\].* |script[/\\].* -)$}x; +}x; + +my $dir_match = qr{ + (?: + . + |lib + |bin + |script + ) + (?:[/\\]|$) +}x; my %files; if ($git) { @@ -33,7 +43,7 @@ if ($git) { for (`git ls-files`) { chomp; next - unless /$file_match/; + unless /^$file_match$/; $files{$_} = `git show HEAD:"$_"`; } } @@ -41,13 +51,18 @@ else { find({ no_chdir => 1, wanted => sub { - next + my $fn = File::Spec->abs2rel($_, '.'); + if (-d && $fn !~ /^$dir_match$/) { + $File::Find::prune = 1; + return; + } + return unless -f; - next - unless /(?:\.[\/\\])?$file_match/; - open my $fh, '<', $_ - or die "can't open $_: $!"; - $files{$_} = do { local $/; <$fh> }; + return + unless $fn =~ /^$file_match$/; + open my $fh, '<', $fn + or die "can't open $fn: $!"; + $files{$fn} = do { local $/; <$fh> }; close $fh; }, }, '.');