← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:11 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/RegularExpressions/ProhibitSingleCharAlternation.pm
StatementsExecuted 23 statements in 529µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11117µs17µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::BEGIN@10Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@10
11111µs22µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::BEGIN@11Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@11
1119µs146µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::BEGIN@16Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@16
1118µs42µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::BEGIN@14Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@14
1118µs37µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::BEGIN@17Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@17
1118µs11µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::BEGIN@12Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@12
1118µs61µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::BEGIN@20Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@20
1117µs377µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::BEGIN@15Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@15
1117µs360µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::BEGIN@19Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@19
1116µs7µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::default_severityPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::default_severity
1112µs2µsPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::supported_parametersPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::supported_parameters
0000s0sPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::__ANON__[:52]Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::__ANON__[:52]
0000s0sPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::applies_toPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::applies_to
0000s0sPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::default_themesPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::default_themes
0000s0sPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::::violatesPerl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::violates
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1##############################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##############################################################################
7
8package Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation;
9
10240µs117µs
# spent 17µs within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@10 which was called: # once (17µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11221µs233µs
# spent 22µs (11+11) within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@11 which was called: # once (11µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 22µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@11 # spent 11µs making 1 call to strict::import
12219µs215µs
# spent 11µs (8+4) within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@12 which was called: # once (8µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 11µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14226µs276µs
# spent 42µs (8+34) within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@14 which was called: # once (8µs+34µs) by Module::Pluggable::Object::_require at line 14
use Carp;
# spent 42µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@14 # spent 34µs making 1 call to Exporter::import
15234µs2746µs
# spent 377µs (7+369) within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@15 which was called: # once (7µs+369µs) by Module::Pluggable::Object::_require at line 15
use English qw(-no_match_vars);
# spent 377µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@15 # spent 369µs making 1 call to English::import
16223µs2282µs
# spent 146µs (9+136) within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@16 which was called: # once (9µs+136µs) by Module::Pluggable::Object::_require at line 16
use List::MoreUtils qw(all);
# spent 146µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@16 # spent 136µs making 1 call to Exporter::Tiny::import
17223µs266µs
# spent 37µs (8+29) within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@17 which was called: # once (8µs+29µs) by Module::Pluggable::Object::_require at line 17
use Readonly;
# spent 37µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@17 # spent 29µs making 1 call to Exporter::import
18
19224µs2713µs
# spent 360µs (7+353) within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@19 which was called: # once (7µs+353µs) by Module::Pluggable::Object::_require at line 19
use Perl::Critic::Utils qw{ :booleans :characters :severities };
# spent 360µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@19 # spent 353µs making 1 call to Exporter::import
202304µs2114µs
# spent 61µs (8+53) within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@20 which was called: # once (8µs+53µs) by Module::Pluggable::Object::_require at line 20
use base 'Perl::Critic::Policy';
# spent 61µs making 1 call to Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::BEGIN@20 # spent 53µs making 1 call to base::import
21
221600nsour $VERSION = '1.121';
23
24#-----------------------------------------------------------------------------
25
2612µs149µsReadonly::Scalar my $EXPL => [265];
# spent 49µs making 1 call to Readonly::Scalar
27
28#-----------------------------------------------------------------------------
29
3015µs
# spent 2µs within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::supported_parameters which was called: # once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters { return qw() }
3111µs
# spent 7µs (6+1) within Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation::default_severity which was called: # once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm
sub default_severity { return $SEVERITY_LOWEST }
32sub default_themes { return qw( core pbp performance ) }
33sub applies_to { return qw(PPI::Token::Regexp::Match
34 PPI::Token::Regexp::Substitute
35 PPI::Token::QuoteLike::Regexp) }
36
37#-----------------------------------------------------------------------------
38
39sub violates {
40 my ( $self, $elem, $document ) = @_;
41
42 # optimization: don't bother parsing the regexp if there are no pipes
43 return if $elem !~ m/[|]/xms;
44
45 my $re = $document->ppix_regexp_from_element( $elem ) or return;
46 $re->failures() and return;
47
48 my @violations;
49 foreach my $node ( @{ $re->find_parents( sub {
50 return $_[1]->isa( 'PPIx::Regexp::Token::Operator' )
51 && $_[1]->content() eq q<|>;
52 } ) || [] } ) {
53
54 my @singles;
55 my @alternative;
56 foreach my $kid ( $node->children() ) {
57 if ( $kid->isa( 'PPIx::Regexp::Token::Operator' )
58 && $kid->content() eq q<|>
59 ) {
60 @alternative == 1
61 and $alternative[0]->isa( 'PPIx::Regexp::Token::Literal' )
62 and push @singles, map { $_->content() } @alternative;
63 @alternative = ();
64 } elsif ( $kid->significant() ) {
65 push @alternative, $kid;
66 }
67 }
68 @alternative == 1
69 and $alternative[0]->isa( 'PPIx::Regexp::Token::Literal' )
70 and push @singles, map { $_->content() } @alternative;
71
72 if ( 1 < @singles ) {
73 my $description =
74 'Use ['
75 . join( $EMPTY, @singles )
76 . '] instead of '
77 . join q<|>, @singles;
78 push @violations, $self->violation( $description, $EXPL, $elem );
79 }
80 }
81
82 return @violations;
83}
84
8516µs1;
86
87__END__