Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Annotation.pm |
Statements | Executed 12520 statements in 71.5ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
51 | 1 | 1 | 43.8ms | 53.0ms | _parse_annotation | Perl::Critic::Annotation::
144 | 1 | 1 | 14.3ms | 1.77s | create_annotations | Perl::Critic::Annotation::
9226 | 5 | 1 | 9.07ms | 12.3ms | CORE:match (opcode) | Perl::Critic::Annotation::
51 | 1 | 1 | 4.92ms | 85.7ms | _init | Perl::Critic::Annotation::
9175 | 4 | 1 | 4.23ms | 4.23ms | CORE:regcomp (opcode) | Perl::Critic::Annotation::
51 | 1 | 1 | 953µs | 7.61ms | _is_single_line_annotation_on_simple_statement | Perl::Critic::Annotation::
208 | 3 | 1 | 495µs | 495µs | CORE:qr (opcode) | Perl::Critic::Annotation::
51 | 1 | 1 | 429µs | 86.1ms | new | Perl::Critic::Annotation::
51 | 1 | 1 | 152µs | 152µs | disabled_policies | Perl::Critic::Annotation::
51 | 1 | 1 | 104µs | 104µs | effective_range | Perl::Critic::Annotation::
51 | 1 | 1 | 96µs | 96µs | disables_all_policies | Perl::Critic::Annotation::
1 | 1 | 1 | 15µs | 15µs | BEGIN@10 | Perl::Critic::Annotation::
1 | 1 | 1 | 10µs | 16µs | BEGIN@17 | Perl::Critic::Annotation::
1 | 1 | 1 | 8µs | 378µs | BEGIN@15 | Perl::Critic::Annotation::
1 | 1 | 1 | 7µs | 26µs | BEGIN@19 | Perl::Critic::Annotation::
1 | 1 | 1 | 7µs | 28µs | BEGIN@14 | Perl::Critic::Annotation::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Perl::Critic::Annotation::
1 | 1 | 1 | 7µs | 314µs | BEGIN@18 | Perl::Critic::Annotation::
1 | 1 | 1 | 7µs | 11µs | BEGIN@12 | Perl::Critic::Annotation::
0 | 0 | 0 | 0s | 0s | disables_line | Perl::Critic::Annotation::
0 | 0 | 0 | 0s | 0s | disables_policy | Perl::Critic::Annotation::
0 | 0 | 0 | 0s | 0s | element | Perl::Critic::Annotation::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ############################################################################## | ||||
2 | # $URL$ | ||||
3 | # $Date$ | ||||
4 | # $Author$ | ||||
5 | # $Revision$ | ||||
6 | ############################################################################## | ||||
7 | |||||
8 | package Perl::Critic::Annotation; | ||||
9 | |||||
10 | 2 | 42µs | 1 | 15µs | # spent 15µs within Perl::Critic::Annotation::BEGIN@10 which was called:
# once (15µs+0s) by Perl::Critic::Document::BEGIN@24 at line 10 # spent 15µs making 1 call to Perl::Critic::Annotation::BEGIN@10 |
11 | 2 | 19µs | 2 | 28µs | # spent 18µs (7+11) within Perl::Critic::Annotation::BEGIN@11 which was called:
# once (7µs+11µs) by Perl::Critic::Document::BEGIN@24 at line 11 # spent 18µs making 1 call to Perl::Critic::Annotation::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 23µs | 2 | 16µs | # spent 11µs (7+5) within Perl::Critic::Annotation::BEGIN@12 which was called:
# once (7µs+5µs) by Perl::Critic::Document::BEGIN@24 at line 12 # spent 11µs making 1 call to Perl::Critic::Annotation::BEGIN@12
# spent 5µs making 1 call to warnings::import |
13 | |||||
14 | 2 | 25µs | 2 | 49µs | # spent 28µs (7+21) within Perl::Critic::Annotation::BEGIN@14 which was called:
# once (7µs+21µs) by Perl::Critic::Document::BEGIN@24 at line 14 # spent 28µs making 1 call to Perl::Critic::Annotation::BEGIN@14
# spent 21µs making 1 call to Exporter::import |
15 | 2 | 24µs | 2 | 749µs | # spent 378µs (8+371) within Perl::Critic::Annotation::BEGIN@15 which was called:
# once (8µs+371µs) by Perl::Critic::Document::BEGIN@24 at line 15 # spent 378µs making 1 call to Perl::Critic::Annotation::BEGIN@15
# spent 371µs making 1 call to English::import |
16 | |||||
17 | 2 | 23µs | 2 | 22µs | # spent 16µs (10+6) within Perl::Critic::Annotation::BEGIN@17 which was called:
# once (10µs+6µs) by Perl::Critic::Document::BEGIN@24 at line 17 # spent 16µs making 1 call to Perl::Critic::Annotation::BEGIN@17
# spent 6µs making 1 call to Perl::Critic::PolicyFactory::import |
18 | 2 | 23µs | 2 | 620µs | # spent 314µs (7+307) within Perl::Critic::Annotation::BEGIN@18 which was called:
# once (7µs+307µs) by Perl::Critic::Document::BEGIN@24 at line 18 # spent 314µs making 1 call to Perl::Critic::Annotation::BEGIN@18
# spent 307µs making 1 call to Exporter::import |
19 | 2 | 828µs | 2 | 46µs | # spent 26µs (7+19) within Perl::Critic::Annotation::BEGIN@19 which was called:
# once (7µs+19µs) by Perl::Critic::Document::BEGIN@24 at line 19 # spent 26µs making 1 call to Perl::Critic::Annotation::BEGIN@19
# spent 19µs making 1 call to Exporter::import |
20 | |||||
21 | #----------------------------------------------------------------------------- | ||||
22 | |||||
23 | 1 | 600ns | our $VERSION = '1.121'; | ||
24 | |||||
25 | 1 | 2µs | 1 | 31µs | Readonly::Scalar my $LAST_ELEMENT => -1; # spent 31µs making 1 call to Readonly::Scalar |
26 | |||||
27 | #============================================================================= | ||||
28 | # CLASS methods | ||||
29 | |||||
30 | # spent 1.77s (14.3ms+1.76) within Perl::Critic::Annotation::create_annotations which was called 144 times, avg 12.3ms/call:
# 144 times (14.3ms+1.76s) by Perl::Critic::Document::process_annotations at line 403 of Perl/Critic/Document.pm, avg 12.3ms/call | ||||
31 | 144 | 73µs | my ($class, $doc) = @_; | ||
32 | |||||
33 | 144 | 113µs | my @annotations = (); | ||
34 | 144 | 340µs | 144 | 1.66s | my $comment_elements_ref = $doc->find('PPI::Token::Comment') || return; # spent 1.66s making 144 calls to Perl::Critic::Document::find, avg 11.6ms/call |
35 | 144 | 803µs | 144 | 402µs | my $annotation_rx = qr{\A (?: [#]! .*? )? \s* [#][#] \s* no \s+ critic}xms; # spent 402µs making 144 calls to Perl::Critic::Annotation::CORE:qr, avg 3µs/call |
36 | 2054 | 17.0ms | 5730 | 12.4ms | for my $annotation_element ( grep { $_ =~ $annotation_rx } @{$comment_elements_ref} ) { # spent 7.63ms making 1910 calls to Perl::Critic::Annotation::CORE:match, avg 4µs/call
# spent 3.00ms making 1910 calls to PPI::Token::content, avg 2µs/call
# spent 1.76ms making 1910 calls to Perl::Critic::Annotation::CORE:regcomp, avg 924ns/call |
37 | 51 | 178µs | 51 | 86.1ms | push @annotations, Perl::Critic::Annotation->new( -element => $annotation_element); # spent 86.1ms making 51 calls to Perl::Critic::Annotation::new, avg 1.69ms/call |
38 | } | ||||
39 | |||||
40 | 144 | 586µs | return @annotations; | ||
41 | } | ||||
42 | |||||
43 | #----------------------------------------------------------------------------- | ||||
44 | |||||
45 | # spent 86.1ms (429µs+85.7) within Perl::Critic::Annotation::new which was called 51 times, avg 1.69ms/call:
# 51 times (429µs+85.7ms) by Perl::Critic::Annotation::create_annotations at line 37, avg 1.69ms/call | ||||
46 | 51 | 54µs | my ($class, @args) = @_; | ||
47 | 51 | 99µs | my $self = bless {}, $class; | ||
48 | 51 | 109µs | 51 | 85.7ms | $self->_init(@args); # spent 85.7ms making 51 calls to Perl::Critic::Annotation::_init, avg 1.68ms/call |
49 | 51 | 131µs | return $self; | ||
50 | } | ||||
51 | |||||
52 | #============================================================================= | ||||
53 | # OBJECT methods | ||||
54 | |||||
55 | # spent 85.7ms (4.92+80.8) within Perl::Critic::Annotation::_init which was called 51 times, avg 1.68ms/call:
# 51 times (4.92ms+80.8ms) by Perl::Critic::Annotation::new at line 48, avg 1.68ms/call | ||||
56 | 51 | 48µs | my ($self, %args) = @_; | ||
57 | 51 | 201µs | 51 | 33µs | my $annotation_element = $args{-element} || confess '-element argument is required'; # spent 33µs making 51 calls to PPI::Util::TRUE, avg 639ns/call |
58 | 51 | 44µs | $self->{_element} = $annotation_element; | ||
59 | |||||
60 | 51 | 159µs | 51 | 53.0ms | my %disabled_policies = _parse_annotation( $annotation_element ); # spent 53.0ms making 51 calls to Perl::Critic::Annotation::_parse_annotation, avg 1.04ms/call |
61 | 51 | 50µs | $self->{_disables_all_policies} = %disabled_policies ? 0 : 1; | ||
62 | 51 | 33µs | $self->{_disabled_policies} = \%disabled_policies; | ||
63 | |||||
64 | # Grab surrounding nodes to determine the context. | ||||
65 | # This determines whether the annotation applies to | ||||
66 | # the current line or the block that follows. | ||||
67 | 51 | 141µs | 51 | 710µs | my $annotation_line = $annotation_element->logical_line_number(); # spent 710µs making 51 calls to PPI::Element::logical_line_number, avg 14µs/call |
68 | 51 | 99µs | 51 | 315µs | my $parent = $annotation_element->parent(); # spent 315µs making 51 calls to PPI::Element::parent, avg 6µs/call |
69 | 51 | 266µs | 102 | 209µs | my $grandparent = $parent ? $parent->parent() : undef; # spent 171µs making 51 calls to PPI::Element::parent, avg 3µs/call
# spent 38µs making 51 calls to PPI::Util::TRUE, avg 735ns/call |
70 | |||||
71 | # Handle case when it appears on the shebang line. In this | ||||
72 | # situation, it only affects the first line, not the whole doc | ||||
73 | 51 | 200µs | 102 | 317µs | if ( $annotation_element =~ m{\A [#]!}xms) { # spent 236µs making 51 calls to Perl::Critic::Annotation::CORE:match, avg 5µs/call
# spent 81µs making 51 calls to PPI::Token::content, avg 2µs/call |
74 | $self->{_effective_range} = [$annotation_line, $annotation_line]; | ||||
75 | return $self; | ||||
76 | } | ||||
77 | |||||
78 | # Handle single-line usage on simple statements. In this | ||||
79 | # situation, it only affects the line that it appears on. | ||||
80 | 51 | 89µs | 51 | 7.61ms | if ( _is_single_line_annotation_on_simple_statement( $annotation_element ) # spent 7.61ms making 51 calls to Perl::Critic::Annotation::_is_single_line_annotation_on_simple_statement, avg 149µs/call |
81 | ) { | ||||
82 | 32 | 38µs | $self->{_effective_range} = [$annotation_line, $annotation_line]; | ||
83 | 32 | 103µs | return $self; | ||
84 | } | ||||
85 | |||||
86 | # Handle single-line usage on compound statements. In this | ||||
87 | # situation -- um -- I'm not sure how this works, but it does. | ||||
88 | 19 | 22µs | if ( ref $parent eq 'PPI::Structure::Block' ) { | ||
89 | 13 | 9µs | if ( ref $grandparent eq 'PPI::Statement::Compound' | ||
90 | || ref $grandparent eq 'PPI::Statement::Sub' ) { | ||||
91 | 12 | 19µs | 12 | 290µs | if ( $parent->logical_line_number() == $annotation_line ) { # spent 290µs making 12 calls to PPI::Element::logical_line_number, avg 24µs/call |
92 | 6 | 17µs | 6 | 104µs | my $grandparent_line = $grandparent->logical_line_number(); # spent 104µs making 6 calls to PPI::Element::logical_line_number, avg 17µs/call |
93 | 6 | 7µs | $self->{_effective_range} = [$grandparent_line, $grandparent_line]; | ||
94 | 6 | 23µs | return $self; | ||
95 | } | ||||
96 | } | ||||
97 | } | ||||
98 | |||||
99 | |||||
100 | # Handle multi-line usage. This is either a "no critic" .. | ||||
101 | # "use critic" region or a block where "no critic" is in effect | ||||
102 | # until the end of the scope. The start is the always the "no | ||||
103 | # critic" which we already found. So now we have to search for the end. | ||||
104 | 13 | 4µs | my $end = $annotation_element; | ||
105 | 13 | 53µs | 13 | 23µs | my $use_critic = qr{\A \s* [#][#] \s* use \s+ critic}xms; # spent 23µs making 13 calls to Perl::Critic::Annotation::CORE:qr, avg 2µs/call |
106 | |||||
107 | SIB: | ||||
108 | 13 | 774µs | 424 | 17.5ms | while ( my $esib = $end->next_sibling() ) { # spent 17.4ms making 216 calls to PPI::Element::next_sibling, avg 80µs/call
# spent 110µs making 208 calls to PPI::Util::TRUE, avg 528ns/call |
109 | 208 | 29µs | $end = $esib; # keep track of last sibling encountered in this scope | ||
110 | 208 | 736µs | 277 | 375µs | last SIB if $esib->isa('PPI::Token::Comment') && $esib =~ $use_critic; # spent 209µs making 208 calls to UNIVERSAL::isa, avg 1µs/call
# spent 103µs making 23 calls to Perl::Critic::Annotation::CORE:match, avg 4µs/call
# spent 35µs making 23 calls to PPI::Token::content, avg 2µs/call
# spent 28µs making 23 calls to Perl::Critic::Annotation::CORE:regcomp, avg 1µs/call |
111 | } | ||||
112 | |||||
113 | # PPI parses __END__ as a PPI::Statement::End, and everything following is | ||||
114 | # a child of that statement. That means if we encounter an __END__, we | ||||
115 | # need to descend into it and continue the analysis. | ||||
116 | 13 | 64µs | 17 | 24µs | if ( $end->isa( 'PPI::Statement::End' ) and my $kid = $end->child( 0 ) ) { # spent 18µs making 13 calls to UNIVERSAL::isa, avg 1µs/call
# spent 5µs making 2 calls to PPI::Node::child, avg 2µs/call
# spent 1µs making 2 calls to PPI::Util::TRUE, avg 550ns/call |
117 | 2 | 500ns | $end = $kid; | ||
118 | SIB: | ||||
119 | 2 | 36µs | 18 | 200µs | while ( my $esib = $end->next_sibling() ) { # spent 196µs making 10 calls to PPI::Element::next_sibling, avg 20µs/call
# spent 4µs making 8 calls to PPI::Util::TRUE, avg 500ns/call |
120 | 8 | 1µs | $end = $esib; | ||
121 | 8 | 23µs | 8 | 8µs | last SIB if $esib->isa( 'PPI::Token::Comment' ) && # spent 8µs making 8 calls to UNIVERSAL::isa, avg 963ns/call |
122 | $esib->content() =~ $use_critic; | ||||
123 | } | ||||
124 | } | ||||
125 | |||||
126 | # We either found an end or hit the end of the scope. | ||||
127 | 13 | 28µs | 13 | 121µs | my $ending_line = $end->logical_line_number(); # spent 121µs making 13 calls to PPI::Element::logical_line_number, avg 9µs/call |
128 | 13 | 16µs | $self->{_effective_range} = [$annotation_line, $ending_line]; | ||
129 | 13 | 52µs | return $self; | ||
130 | } | ||||
131 | |||||
132 | #----------------------------------------------------------------------------- | ||||
133 | |||||
134 | sub element { | ||||
135 | my ($self) = @_; | ||||
136 | return $self->{_element}; | ||||
137 | } | ||||
138 | |||||
139 | #----------------------------------------------------------------------------- | ||||
140 | |||||
141 | # spent 104µs within Perl::Critic::Annotation::effective_range which was called 51 times, avg 2µs/call:
# 51 times (104µs+0s) by Perl::Critic::Document::add_annotation at line 435 of Perl/Critic/Document.pm, avg 2µs/call | ||||
142 | 51 | 14µs | my $self = shift; | ||
143 | 51 | 139µs | return @{ $self->{_effective_range} }; | ||
144 | } | ||||
145 | |||||
146 | #----------------------------------------------------------------------------- | ||||
147 | |||||
148 | # spent 152µs within Perl::Critic::Annotation::disabled_policies which was called 51 times, avg 3µs/call:
# 51 times (152µs+0s) by Perl::Critic::Document::add_annotation at line 436 of Perl/Critic/Document.pm, avg 3µs/call | ||||
149 | 51 | 13µs | my $self = shift; | ||
150 | 51 | 180µs | return keys %{ $self->{_disabled_policies} }; | ||
151 | } | ||||
152 | |||||
153 | #----------------------------------------------------------------------------- | ||||
154 | |||||
155 | sub disables_policy { | ||||
156 | my ($self, $policy_name) = @_; | ||||
157 | return 1 if $self->{_disabled_policies}->{$policy_name}; | ||||
158 | return 1 if $self->disables_all_policies(); | ||||
159 | return 0; | ||||
160 | } | ||||
161 | |||||
162 | #----------------------------------------------------------------------------- | ||||
163 | |||||
164 | # spent 96µs within Perl::Critic::Annotation::disables_all_policies which was called 51 times, avg 2µs/call:
# 51 times (96µs+0s) by Perl::Critic::Document::add_annotation at line 436 of Perl/Critic/Document.pm, avg 2µs/call | ||||
165 | 51 | 15µs | my ($self) = @_; | ||
166 | 51 | 110µs | return $self->{_disables_all_policies}; | ||
167 | } | ||||
168 | |||||
169 | #----------------------------------------------------------------------------- | ||||
170 | |||||
171 | sub disables_line { | ||||
172 | my ($self, $line_number) = @_; | ||||
173 | my $effective_range = $self->{_effective_range}; | ||||
174 | return 1 if $line_number >= $effective_range->[0] | ||||
175 | and $line_number <= $effective_range->[$LAST_ELEMENT]; | ||||
176 | return 0; | ||||
177 | } | ||||
178 | |||||
179 | #----------------------------------------------------------------------------- | ||||
180 | |||||
181 | # Recognize a single-line annotation on a simple statement. | ||||
182 | # spent 7.61ms (953µs+6.66) within Perl::Critic::Annotation::_is_single_line_annotation_on_simple_statement which was called 51 times, avg 149µs/call:
# 51 times (953µs+6.66ms) by Perl::Critic::Annotation::_init at line 80, avg 149µs/call | ||||
183 | 51 | 18µs | my ( $annotation_element ) = @_; | ||
184 | 51 | 87µs | 51 | 410µs | my $annotation_line = $annotation_element->logical_line_number(); # spent 410µs making 51 calls to PPI::Element::logical_line_number, avg 8µs/call |
185 | |||||
186 | # If there is no sibling, we are clearly not a single-line annotation of | ||||
187 | # any sort. | ||||
188 | 51 | 252µs | 92 | 5.06ms | my $sib = $annotation_element->sprevious_sibling() # spent 5.04ms making 51 calls to PPI::Element::sprevious_sibling, avg 99µs/call
# spent 27µs making 41 calls to PPI::Util::TRUE, avg 654ns/call |
189 | or return 0; | ||||
190 | |||||
191 | # The easy case: the sibling (whatever it is) is on the same line as the | ||||
192 | # annotation. | ||||
193 | 41 | 138µs | 41 | 660µs | $sib->logical_line_number() == $annotation_line # spent 660µs making 41 calls to PPI::Element::logical_line_number, avg 16µs/call |
194 | and return 1; | ||||
195 | |||||
196 | # If the sibling is a node, we may have an annotation on one line of a | ||||
197 | # statement that was split over multiple lines. So we descend through the | ||||
198 | # children, keeping the last significant child of each, until we bottom | ||||
199 | # out. If the ultimate significant descendant is on the same line as the | ||||
200 | # annotation, we accept the annotation as a single-line annotation. | ||||
201 | 12 | 80µs | 24 | 171µs | if ( $sib->isa( 'PPI::Node' ) && # spent 150µs making 12 calls to PPI::Element::logical_line_number, avg 12µs/call
# spent 21µs making 12 calls to UNIVERSAL::isa, avg 2µs/call |
202 | $sib->logical_line_number() < $annotation_line | ||||
203 | ) { | ||||
204 | 12 | 3µs | my $neighbor = $sib; | ||
205 | 12 | 165µs | 60 | 248µs | while ( $neighbor->isa( 'PPI::Node' ) # spent 212µs making 16 calls to PPI::Node::schild, avg 13µs/call
# spent 26µs making 28 calls to UNIVERSAL::isa, avg 939ns/call
# spent 10µs making 16 calls to PPI::Util::TRUE, avg 625ns/call |
206 | and my $kid = $neighbor->schild( $LAST_ELEMENT ) ) { | ||||
207 | $neighbor = $kid; | ||||
208 | } | ||||
209 | 12 | 63µs | 24 | 107µs | if ( $neighbor && # spent 101µs making 12 calls to PPI::Element::logical_line_number, avg 8µs/call
# spent 6µs making 12 calls to PPI::Util::TRUE, avg 517ns/call |
210 | $neighbor->logical_line_number() == $annotation_line | ||||
211 | ) { | ||||
212 | return 1; | ||||
213 | } | ||||
214 | } | ||||
215 | |||||
216 | # We do not understand any other sort of single-line annotation. Accepting | ||||
217 | # the annotation as such (if it is) is Someone Else's Problem. | ||||
218 | 9 | 21µs | return 0; | ||
219 | } | ||||
220 | |||||
221 | #----------------------------------------------------------------------------- | ||||
222 | |||||
223 | # spent 53.0ms (43.8+9.28) within Perl::Critic::Annotation::_parse_annotation which was called 51 times, avg 1.04ms/call:
# 51 times (43.8ms+9.28ms) by Perl::Critic::Annotation::_init at line 60, avg 1.04ms/call | ||||
224 | |||||
225 | 51 | 17µs | my ($annotation_element) = @_; | ||
226 | |||||
227 | ############################################################################# | ||||
228 | # This regex captures the list of Policy name patterns that are to be | ||||
229 | # disabled. It is generally assumed that the element has already been | ||||
230 | # verified as a no-critic annotation. So if this regex does not match, | ||||
231 | # then it implies that all Policies are to be disabled. | ||||
232 | # | ||||
233 | 51 | 178µs | 51 | 69µs | my $no_critic = qr{\#\# \s* no \s+ critic \s* (?:qw)? [("'] ([\s\w:,]+) }xms; # spent 69µs making 51 calls to Perl::Critic::Annotation::CORE:qr, avg 1µs/call |
234 | # -------------------------- ------- ----- ----------- | ||||
235 | # | | | | | ||||
236 | # "## no critic" with optional spaces | | | | ||||
237 | # | | | | ||||
238 | # Policy list may be prefixed with "qw" | | | ||||
239 | # | | | ||||
240 | # Optional Policy list must begin with one of these | | ||||
241 | # | | ||||
242 | # Capture entire Policy list (with delimiters) here | ||||
243 | # | ||||
244 | ############################################################################# | ||||
245 | |||||
246 | 51 | 23µs | my @disabled_policy_names = (); | ||
247 | 51 | 557µs | 153 | 510µs | if ( my ($patterns_string) = $annotation_element =~ $no_critic ) { # spent 358µs making 51 calls to Perl::Critic::Annotation::CORE:match, avg 7µs/call
# spent 77µs making 51 calls to PPI::Token::content, avg 2µs/call
# spent 75µs making 51 calls to Perl::Critic::Annotation::CORE:regcomp, avg 1µs/call |
248 | |||||
249 | # Compose the specified modules into a regex alternation. Wrap each | ||||
250 | # in a no-capturing group to permit "|" in the modules specification. | ||||
251 | |||||
252 | 51 | 387µs | 59 | 130µs | my @policy_name_patterns = grep { $_ ne $EMPTY } # spent 130µs making 59 calls to Readonly::Scalar::FETCH, avg 2µs/call |
253 | split m{\s *[,\s] \s*}xms, $patterns_string; | ||||
254 | 51 | 240µs | 51 | 64µs | my $re = join $PIPE, map {"(?:$_)"} @policy_name_patterns; # spent 64µs making 51 calls to Readonly::Scalar::FETCH, avg 1µs/call |
255 | 51 | 572µs | 51 | 2.09ms | my @site_policy_names = Perl::Critic::PolicyFactory::site_policy_names(); # spent 2.09ms making 51 calls to Perl::Critic::PolicyFactory::site_policy_names, avg 41µs/call |
256 | 7242 | 43.9ms | 14382 | 6.30ms | @disabled_policy_names = grep {m/$re/ixms} @site_policy_names; # spent 3.94ms making 7191 calls to Perl::Critic::Annotation::CORE:match, avg 548ns/call
# spent 2.36ms making 7191 calls to Perl::Critic::Annotation::CORE:regcomp, avg 329ns/call |
257 | |||||
258 | # It is possible that the Policy patterns listed in the annotation do not | ||||
259 | # match any of the site policy names. This could happen when running | ||||
260 | # on a machine that does not have the same set of Policies as the author. | ||||
261 | # So we must return something here, otherwise all Policies will be | ||||
262 | # disabled. We probably need to add a mechanism to (optionally) warn | ||||
263 | # about this, just to help the author avoid writing invalid Policy names. | ||||
264 | |||||
265 | 51 | 214µs | if (not @disabled_policy_names) { | ||
266 | @disabled_policy_names = @policy_name_patterns; | ||||
267 | } | ||||
268 | } | ||||
269 | |||||
270 | 51 | 288µs | 51 | 190µs | return hashify(@disabled_policy_names); # spent 190µs making 51 calls to Perl::Critic::Utils::hashify, avg 4µs/call |
271 | } | ||||
272 | |||||
273 | #----------------------------------------------------------------------------- | ||||
274 | |||||
275 | 1 | 3µs | 1; | ||
276 | |||||
277 | __END__ | ||||
# spent 12.3ms (9.07+3.20) within Perl::Critic::Annotation::CORE:match which was called 9226 times, avg 1µs/call:
# 7191 times (3.94ms+0s) by Perl::Critic::Annotation::_parse_annotation at line 256, avg 548ns/call
# 1910 times (4.63ms+3.00ms) by Perl::Critic::Annotation::create_annotations at line 36, avg 4µs/call
# 51 times (280µs+77µs) by Perl::Critic::Annotation::_parse_annotation at line 247, avg 7µs/call
# 51 times (155µs+81µs) by Perl::Critic::Annotation::_init at line 73, avg 5µs/call
# 23 times (68µs+35µs) by Perl::Critic::Annotation::_init at line 110, avg 4µs/call | |||||
# spent 495µs within Perl::Critic::Annotation::CORE:qr which was called 208 times, avg 2µs/call:
# 144 times (402µs+0s) by Perl::Critic::Annotation::create_annotations at line 35, avg 3µs/call
# 51 times (69µs+0s) by Perl::Critic::Annotation::_parse_annotation at line 233, avg 1µs/call
# 13 times (23µs+0s) by Perl::Critic::Annotation::_init at line 105, avg 2µs/call | |||||
# spent 4.23ms within Perl::Critic::Annotation::CORE:regcomp which was called 9175 times, avg 461ns/call:
# 7191 times (2.36ms+0s) by Perl::Critic::Annotation::_parse_annotation at line 256, avg 329ns/call
# 1910 times (1.76ms+0s) by Perl::Critic::Annotation::create_annotations at line 36, avg 924ns/call
# 51 times (75µs+0s) by Perl::Critic::Annotation::_parse_annotation at line 247, avg 1µs/call
# 23 times (28µs+0s) by Perl::Critic::Annotation::_init at line 110, avg 1µs/call |