| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Ack::Filter::IsGroup; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
App::Ack::Filter::IsGroup |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
The App::Ack::Filter::IsGroup class optimizes multiple |
|
10
|
|
|
|
|
|
|
App::Ack::Filter::Is calls into one container. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Let's say you have 100 C<--type-add=is:...> filters. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
You could have |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @filters = map { make_is_filter($_) } 1..100; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
and then do |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if ( any { $_->filter($rsrc) } @filters ) { ... } |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
but that's slow, because of of method lookup overhead, function call |
|
23
|
|
|
|
|
|
|
overhead, etc. So ::Is filters know how to organize themselves into an |
|
24
|
|
|
|
|
|
|
::IsGroup filter. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
1377
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
50
|
|
|
29
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
43
|
|
|
30
|
2
|
|
|
2
|
|
8
|
use parent 'App::Ack::Filter'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
6
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
|
33
|
0
|
|
|
0
|
0
|
|
my ( $class ) = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
return bless { |
|
36
|
|
|
|
|
|
|
data => {}, |
|
37
|
|
|
|
|
|
|
}, $class; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub add { |
|
41
|
0
|
|
|
0
|
0
|
|
my ( $self, $filter ) = @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
$self->{data}->{ $filter->{filename} } = 1; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
return; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub filter { |
|
49
|
0
|
|
|
0
|
1
|
|
my ( $self, $file ) = @_; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return exists $self->{data}->{ $file->basename }; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub inspect { |
|
55
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return ref($self) . " - $self"; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub to_string { |
|
61
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return join(' ', keys %{$self->{data}}); |
|
|
0
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |