Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm |
Statements | Executed 27190 statements in 83.4ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
13481 | 1 | 1 | 112ms | 151ms | violates | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
144 | 1 | 1 | 281µs | 281µs | applies_to | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
6 | 1 | 1 | 77µs | 189µs | _recover_open_encoding | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
6 | 2 | 1 | 55µs | 98µs | _get_argument_string | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 16µs | 16µs | BEGIN@10 | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
5 | 1 | 1 | 15µs | 15µs | CORE:subst (opcode) | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 10µs | 21µs | BEGIN@11 | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 8µs | 16µs | _recover_binmode_encoding | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 7µs | 9µs | default_severity | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 7µs | 11µs | BEGIN@12 | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 7µs | 28µs | BEGIN@14 | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 7µs | 20µs | BEGIN@16 | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 7µs | 62µs | BEGIN@19 | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 7µs | 188µs | BEGIN@18 | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 2µs | 2µs | supported_parameters | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
1 | 1 | 1 | 300ns | 300ns | CORE:match (opcode) | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ############################################################################## | ||||
2 | # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/Perl-Critic/lib/Perl/Critic/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm $ | ||||
3 | # $Date: 2010-06-22 16:14:07 -0400 (Tue, 22 Jun 2010) $ | ||||
4 | # $Author: clonezone $ | ||||
5 | # $Revision: 3843 $ | ||||
6 | ############################################################################## | ||||
7 | |||||
8 | package Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer; | ||||
9 | |||||
10 | 2 | 39µs | 1 | 16µs | # spent 16µs within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@10 which was called:
# once (16µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 16µs making 1 call to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@10 |
11 | 2 | 20µs | 2 | 32µs | # spent 21µs (10+11) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@11 which was called:
# once (10µs+11µs) by Module::Pluggable::Object::_require at line 11 # spent 21µs making 1 call to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 18µs | 2 | 15µs | # spent 11µs (7+4) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@12 which was called:
# once (7µs+4µs) by Module::Pluggable::Object::_require at line 12 # spent 11µs making 1 call to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | |||||
14 | 2 | 19µs | 2 | 49µs | # spent 28µs (7+21) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@14 which was called:
# once (7µs+21µs) by Module::Pluggable::Object::_require at line 14 # spent 28µs making 1 call to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@14
# spent 21µs making 1 call to Exporter::import |
15 | |||||
16 | 2 | 21µs | 2 | 33µs | # spent 20µs (7+13) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@16 which was called:
# once (7µs+13µs) by Module::Pluggable::Object::_require at line 16 # spent 20µs making 1 call to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@16
# spent 13µs making 1 call to version::import |
17 | |||||
18 | 2 | 22µs | 2 | 369µs | # spent 188µs (7+181) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@18 which was called:
# once (7µs+181µs) by Module::Pluggable::Object::_require at line 18 # spent 188µs making 1 call to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@18
# spent 181µs making 1 call to Exporter::import |
19 | 2 | 327µs | 2 | 116µs | # spent 62µs (7+55) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@19 which was called:
# once (7µs+55µs) by Module::Pluggable::Object::_require at line 19 # spent 62µs making 1 call to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::BEGIN@19
# spent 55µs making 1 call to base::import |
20 | |||||
21 | 1 | 600ns | our $VERSION = '1.121'; | ||
22 | |||||
23 | #----------------------------------------------------------------------------- | ||||
24 | |||||
25 | 1 | 2µs | 1 | 29µs | Readonly::Scalar my $DESC => q{I/O layer ":utf8" used}; # spent 29µs making 1 call to Readonly::Scalar |
26 | 1 | 1µs | 1 | 21µs | Readonly::Scalar my $EXPL => q{Use ":encoding(UTF-8)" to get strict validation}; # spent 21µs making 1 call to Readonly::Scalar |
27 | |||||
28 | 1 | 900ns | 1 | 20µs | Readonly::Scalar my $THREE_ARGUMENT_OPEN => 3; # spent 20µs making 1 call to Readonly::Scalar |
29 | 1 | 2µs | 1 | 23µs | Readonly::Hash my %RECOVER_ENCODING => ( # spent 23µs making 1 call to Readonly::Hash |
30 | binmode => \&_recover_binmode_encoding, | ||||
31 | open => \&_recover_open_encoding, | ||||
32 | ); | ||||
33 | |||||
34 | #----------------------------------------------------------------------------- | ||||
35 | |||||
36 | 1 | 5µs | # spent 2µs within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::supported_parameters which was called:
# once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||
37 | 1 | 2µs | # spent 9µs (7+2) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::default_severity which was called:
# once (7µs+2µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
38 | sub default_themes { return qw(core bugs security) } | ||||
39 | 144 | 368µs | # spent 281µs within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::applies_to which was called 144 times, avg 2µs/call:
# 144 times (281µs+0s) by Perl::Critic::_critique at line 165 of Perl/Critic.pm, avg 2µs/call | ||
40 | |||||
41 | #----------------------------------------------------------------------------- | ||||
42 | |||||
43 | # spent 151ms (112+38.6) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::violates which was called 13481 times, avg 11µs/call:
# 13481 times (112ms+38.6ms) by Perl::Critic::_critique at line 183 of Perl/Critic.pm, avg 11µs/call | ||||
44 | 13481 | 3.05ms | my ($self, $elem, $document) = @_; | ||
45 | |||||
46 | 13481 | 79.4ms | 26962 | 34.8ms | my $handler = $RECOVER_ENCODING{ $elem->content() } # spent 18.5ms making 13481 calls to Readonly::Hash::FETCH, avg 1µs/call
# spent 16.4ms making 13481 calls to PPI::Token::content, avg 1µs/call |
47 | or return; # If we don't have a handler, we're not interested. | ||||
48 | 7 | 34µs | 14 | 3.73ms | my $encoding = $handler->( parse_arg_list( $elem ) ) # spent 3.52ms making 7 calls to Perl::Critic::Utils::parse_arg_list, avg 503µs/call
# spent 189µs making 6 calls to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_recover_open_encoding, avg 31µs/call
# spent 16µs making 1 call to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_recover_binmode_encoding |
49 | or return; # If we can't recover an encoding, we give up. | ||||
50 | 1 | 9µs | 1 | 300ns | return if $encoding !~ m/ (?: \A | : ) utf8 \b /smxi; # OK # spent 300ns making 1 call to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::CORE:match |
51 | |||||
52 | return $self->violation( $DESC, $EXPL, $elem ); | ||||
53 | } | ||||
54 | |||||
55 | #----------------------------------------------------------------------------- | ||||
56 | |||||
57 | # my $string = _get_argument_string( $arg[1] ); | ||||
58 | # | ||||
59 | # This subroutine returns the string from the given argument (which must | ||||
60 | # be a reference to an array of PPI objects), _PROVIDED_ the array | ||||
61 | # contains a single PPI::Token::Quote object. Otherwise it simply | ||||
62 | # returns, since we're too stupid to analyze anything else. | ||||
63 | |||||
64 | # spent 98µs (55+42) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_get_argument_string which was called 6 times, avg 16µs/call:
# 5 times (48µs+41µs) by Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_recover_open_encoding at line 95, avg 18µs/call
# once (6µs+1µs) by Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_recover_binmode_encoding at line 81 | ||||
65 | 6 | 2µs | my ( $arg ) = @_; | ||
66 | 6 | 4µs | ref $arg eq 'ARRAY' or return; | ||
67 | 6 | 5µs | return if @{ $arg } == 0 || @{ $arg } > 1; | ||
68 | 6 | 47µs | 11 | 42µs | return $arg->[0]->string() if $arg->[0]->isa( 'PPI::Token::Quote' ); # spent 19µs making 1 call to PPI::Token::Quote::Literal::string
# spent 18µs making 4 calls to PPI::Token::Quote::Single::string, avg 4µs/call
# spent 6µs making 6 calls to UNIVERSAL::isa, avg 917ns/call |
69 | 1 | 5µs | return; | ||
70 | } | ||||
71 | |||||
72 | #----------------------------------------------------------------------------- | ||||
73 | |||||
74 | # my $encoding = _recover_binmode_encoding( _parse_arg_list( $elem ) ); | ||||
75 | # | ||||
76 | # This subroutine returns the encoding specified by the given $elem, | ||||
77 | # which _MUST_ be the 'binmode' of a binmode() call. | ||||
78 | |||||
79 | # spent 16µs (8+8) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_recover_binmode_encoding which was called:
# once (8µs+8µs) by Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::violates at line 48 | ||||
80 | 1 | 900ns | my ( @args ) = @_; | ||
81 | 1 | 5µs | 1 | 8µs | return _get_argument_string( $args[1] ); # spent 8µs making 1 call to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_get_argument_string |
82 | } | ||||
83 | |||||
84 | #----------------------------------------------------------------------------- | ||||
85 | |||||
86 | # my $encoding = _recover_open_encoding( _parse_arg_list( $elem ) ); | ||||
87 | # | ||||
88 | # This subroutine returns the encoding specified by the given $elem, | ||||
89 | # which _MUST_ be the 'open' of a open() call. | ||||
90 | |||||
91 | # spent 189µs (77+111) within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_recover_open_encoding which was called 6 times, avg 31µs/call:
# 6 times (77µs+111µs) by Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::violates at line 48, avg 31µs/call | ||||
92 | 6 | 4µs | my ( @args ) = @_; | ||
93 | 6 | 16µs | 6 | 6µs | @args < $THREE_ARGUMENT_OPEN # spent 6µs making 6 calls to Readonly::Scalar::FETCH, avg 1µs/call |
94 | and return; | ||||
95 | 5 | 11µs | 5 | 90µs | defined( my $string = _get_argument_string( $args[1] ) ) # spent 90µs making 5 calls to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_get_argument_string, avg 18µs/call |
96 | or return; | ||||
97 | 5 | 31µs | 5 | 15µs | $string =~ s/ [+]? (?: < | >{1,2} ) //smx; # spent 15µs making 5 calls to Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::CORE:subst, avg 3µs/call |
98 | 5 | 15µs | return $string; | ||
99 | } | ||||
100 | |||||
101 | 1 | 5µs | 1; | ||
102 | |||||
103 | __END__ | ||||
# spent 300ns within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::CORE:match which was called:
# once (300ns+0s) by Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::violates at line 50 | |||||
# spent 15µs within Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::CORE:subst which was called 5 times, avg 3µs/call:
# 5 times (15µs+0s) by Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_recover_open_encoding at line 97, avg 3µs/call |