Skip to content

Commit

Permalink
optimize with basename()
Browse files Browse the repository at this point in the history
  • Loading branch information
xdg committed Jan 21, 2013
1 parent 28eefe3 commit 37b225c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ Revision history for Path-Class-Rule

{{$NEXT}}

[OPTIMIZATION]

- Use Path::Class's basename() internally,, resulting in a 50%
speedup on a test case of finding all .pm files in @INC; requires
Path::Class 0.20.

0.013 2012-12-13 11:08:42 America/New_York

[DOCUMENTATION]
Expand Down
8 changes: 4 additions & 4 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"David Golden <dagolden@cpan.org>"
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 4.300028, CPAN::Meta::Converter version 2.120921",
"generated_by" : "Dist::Zilla version 4.300029, CPAN::Meta::Converter version 2.120921",
"license" : [
"apache_2_0"
],
Expand Down Expand Up @@ -42,7 +42,7 @@
"Data::Clone" : "0",
"List::Util" : "0",
"Number::Compare" : "0.02",
"Path::Class::Dir" : "0",
"Path::Class::Dir" : "0.22",
"Scalar::Util" : "0",
"Text::Glob" : "0",
"Try::Tiny" : "0",
Expand Down Expand Up @@ -70,7 +70,7 @@
"provides" : {
"Path::Class::Rule" : {
"file" : "lib/Path/Class/Rule.pm",
"version" : "0.013"
"version" : "0.014"
}
},
"release_status" : "stable",
Expand All @@ -86,6 +86,6 @@
"web" : "https://github.com/dagolden/path-class-rule"
}
},
"version" : "0.013"
"version" : "0.014"
}

6 changes: 5 additions & 1 deletion README.pod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Path::Class::Rule - File finder using Path::Class

=head1 VERSION

version 0.013
version 0.014

=head1 SYNOPSIS

Expand Down Expand Up @@ -528,6 +528,10 @@ Extension class loading via C<import()>
Filetest operators and stat rules are subject to the usual portability
considerations. See L<perlport> for details.

Performance suffers somewhat from all of the abstraction layers
of L<Path::Class> and L<File::Spec>. Hopefully, convenience
makes up for that.

=head1 SEE ALSO

There are many other file finding modules out there. They all have various
Expand Down
10 changes: 7 additions & 3 deletions lib/Path/Class/Rule.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use Carp;
use Data::Clone qw/data_clone/;
use List::Util qw/first/;
use Number::Compare 0.02;
use Path::Class::Dir qw();
use Path::Class::Dir 0.22 ();
use Scalar::Util qw/blessed/;
use Text::Glob qw/glob_to_regex/;
use Try::Tiny;
Expand Down Expand Up @@ -285,7 +285,7 @@ my %complex_helpers = (
my @patterns = map { _regexify($_) } @_;
return sub {
my $f = shift;
my $name = $f->relative($f->parent);
my $name = $f->basename;
return (first { $name =~ $_} @patterns ) ? 1 : 0;
}
},
Expand All @@ -294,7 +294,7 @@ my %complex_helpers = (
my @patterns = map { _regexify($_, "i") } @_;
return sub {
my $f = shift;
my $name = $f->relative($f->parent);
my $name = $f->basename;
return (first { $name =~ m{$_}i } @patterns ) ? 1 : 0;
}
},
Expand Down Expand Up @@ -921,6 +921,10 @@ Some features are still unimplemented:
Filetest operators and stat rules are subject to the usual portability
considerations. See L<perlport> for details.
Performance suffers somewhat from all of the abstraction layers
of L<Path::Class> and L<File::Spec>. Hopefully, convenience
makes up for that.
=head1 SEE ALSO
There are many other file finding modules out there. They all have various
Expand Down

0 comments on commit 37b225c

Please sign in to comment.