← 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:10 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Token/BOM.pm
StatementsExecuted 730 statements in 2.59ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
144112.16ms4.66msPPI::Token::BOM::::__TOKENIZER__on_line_startPPI::Token::BOM::__TOKENIZER__on_line_start
14411260µs260µsPPI::Token::BOM::::CORE:matchPPI::Token::BOM::CORE:match (opcode)
11114µs26µsPPI::Token::BOM::::BEGIN@42PPI::Token::BOM::BEGIN@42
1118µs8µsPPI::Token::BOM::::BEGIN@46PPI::Token::BOM::BEGIN@46
1116µs33µsPPI::Token::BOM::::BEGIN@45PPI::Token::BOM::BEGIN@45
1113µs3µsPPI::Token::BOM::::BEGIN@43PPI::Token::BOM::BEGIN@43
0000s0sPPI::Token::BOM::::significantPPI::Token::BOM::significant
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package PPI::Token::BOM;
2
3=pod
4
5=head1 NAME
6
7PPI::Token::BOM - Tokens representing Unicode byte order marks
8
9=head1 INHERITANCE
10
11 PPI::Token::BOM
12 isa PPI::Token
13 isa PPI::Element
14
15=head1 DESCRIPTION
16
17This is a special token in that it can only occur at the beginning of
18documents. If a BOM byte mark occurs elsewhere in a file, it should
19be treated as L<PPI::Token::Whitespace>. We recognize the byte order
20marks identified at this URL:
21L<http://www.unicode.org/faq/utf_bom.html#BOM>
22
23 UTF-32, big-endian 00 00 FE FF
24 UTF-32, little-endian FF FE 00 00
25 UTF-16, big-endian FE FF
26 UTF-16, little-endian FF FE
27 UTF-8 EF BB BF
28
29Note that as of this writing, PPI only has support for UTF-8
30(namely, in POD and strings) and no support for UTF-16 or UTF-32. We
31support the BOMs of the latter two for completeness only.
32
33The BOM is considered non-significant, like white space.
34
35=head1 METHODS
36
37There are no additional methods beyond those provided by the parent
38L<PPI::Token> and L<PPI::Element> classes.
39
40=cut
41
42218µs238µs
# spent 26µs (14+12) within PPI::Token::BOM::BEGIN@42 which was called: # once (14µs+12µs) by PPI::Token::BEGIN@38 at line 42
use strict;
# spent 26µs making 1 call to PPI::Token::BOM::BEGIN@42 # spent 12µs making 1 call to strict::import
43218µs13µs
# spent 3µs within PPI::Token::BOM::BEGIN@43 which was called: # once (3µs+0s) by PPI::Token::BEGIN@38 at line 43
use PPI::Token ();
# spent 3µs making 1 call to PPI::Token::BOM::BEGIN@43
44
45227µs260µs
# spent 33µs (6+27) within PPI::Token::BOM::BEGIN@45 which was called: # once (6µs+27µs) by PPI::Token::BEGIN@38 at line 45
use vars qw{$VERSION @ISA};
# spent 33µs making 1 call to PPI::Token::BOM::BEGIN@45 # spent 27µs making 1 call to vars::import
46
# spent 8µs within PPI::Token::BOM::BEGIN@46 which was called: # once (8µs+0s) by PPI::Token::BEGIN@38 at line 49
BEGIN {
471400ns $VERSION = '1.215';
4818µs @ISA = 'PPI::Token';
491181µs18µs}
# spent 8µs making 1 call to PPI::Token::BOM::BEGIN@46
50
51sub significant { '' }
52
- -
57#####################################################################
58# Parsing Methods
59
6013µsmy %bom_types = (
61 "\x00\x00\xfe\xff" => 'UTF-32',
62 "\xff\xfe\x00\x00" => 'UTF-32',
63 "\xfe\xff" => 'UTF-16',
64 "\xff\xfe" => 'UTF-16',
65 "\xef\xbb\xbf" => 'UTF-8',
66);
67
68
# spent 4.66ms (2.16+2.50) within PPI::Token::BOM::__TOKENIZER__on_line_start which was called 144 times, avg 32µs/call: # 144 times (2.16ms+2.50ms) by PPI::Tokenizer::_process_next_line at line 499 of PPI/Tokenizer.pm, avg 32µs/call
sub __TOKENIZER__on_line_start {
6914456µs my $t = $_[1];
70144110µs $_ = $t->{line};
71
72144715µs144260µs if (m/^(\x00\x00\xfe\xff | # UTF-32, big-endian
# spent 260µs making 144 calls to PPI::Token::BOM::CORE:match, avg 2µs/call
73 \xff\xfe\x00\x00 | # UTF-32, little-endian
74 \xfe\xff | # UTF-16, big-endian
75 \xff\xfe | # UTF-16, little-endian
76 \xef\xbb\xbf) # UTF-8
77 /xs) {
78 my $bom = $1;
79
80 if ($bom_types{$bom} ne 'UTF-8') {
81 return $t->_error("$bom_types{$bom} is not supported");
82 }
83
84 $t->_new_token('BOM', $bom) or return undef;
85 $t->{line_cursor} += length $bom;
86 }
87
88 # Continue just as if there was no BOM
89144339µs $t->{class} = 'PPI::Token::Whitespace';
901441.11ms1442.24ms return $t->{class}->__TOKENIZER__on_line_start($t);
# spent 2.24ms making 144 calls to PPI::Token::Whitespace::__TOKENIZER__on_line_start, avg 16µs/call
91}
92
9314µs1;
94
95=pod
96
97=head1 SUPPORT
98
99See the L<support section|PPI/SUPPORT> in the main module
100
101=head1 AUTHOR
102
103Chris Dolan E<lt>cdolan@cpan.orgE<gt>
104
105=head1 COPYRIGHT
106
107Copyright 2001 - 2011 Adam Kennedy.
108
109This program is free software; you can redistribute
110it and/or modify it under the same terms as Perl itself.
111
112The full text of the license can be found in the
113LICENSE file included with this module.
114
115=cut
 
# spent 260µs within PPI::Token::BOM::CORE:match which was called 144 times, avg 2µs/call: # 144 times (260µs+0s) by PPI::Token::BOM::__TOKENIZER__on_line_start at line 72, avg 2µs/call
sub PPI::Token::BOM::CORE:match; # opcode