← 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/DashedWord.pm
StatementsExecuted 20 statements in 262µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21140µs69µsPPI::Token::DashedWord::::__TOKENIZER__on_charPPI::Token::DashedWord::__TOKENIZER__on_char
11112µs24µsPPI::Token::DashedWord::::BEGIN@29PPI::Token::DashedWord::BEGIN@29
1118µs8µsPPI::Token::DashedWord::::BEGIN@33PPI::Token::DashedWord::BEGIN@33
1117µs35µsPPI::Token::DashedWord::::BEGIN@32PPI::Token::DashedWord::BEGIN@32
4214µs4µsPPI::Token::DashedWord::::CORE:matchPPI::Token::DashedWord::CORE:match (opcode)
1113µs3µsPPI::Token::DashedWord::::BEGIN@30PPI::Token::DashedWord::BEGIN@30
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::DashedWord;
2
3=pod
4
5=head1 NAME
6
7PPI::Token::DashedWord - A dashed bareword token
8
9=head1 INHERITANCE
10
11 PPI::Token::DashedWord
12 isa PPI::Token
13 isa PPI::Element
14
15=head1 DESCRIPTION
16
17The "dashed bareword" token represents literal values like C<-foo>.
18
19NOTE: this class is currently unused. All tokens that should be
20PPI::Token::DashedWords are just normal PPI::Token::Word instead.
21That actually makes sense, since there really is nothing special about
22this class except that dashed words cannot be subroutine names or
23keywords. As such, this class may be removed from PPI in the future.
24
25=head1 METHODS
26
27=cut
28
29220µs236µs
# spent 24µs (12+12) within PPI::Token::DashedWord::BEGIN@29 which was called: # once (12µs+12µs) by PPI::Token::BEGIN@50 at line 29
use strict;
# spent 24µs making 1 call to PPI::Token::DashedWord::BEGIN@29 # spent 12µs making 1 call to strict::import
30219µs13µs
# spent 3µs within PPI::Token::DashedWord::BEGIN@30 which was called: # once (3µs+0s) by PPI::Token::BEGIN@50 at line 30
use PPI::Token ();
# spent 3µs making 1 call to PPI::Token::DashedWord::BEGIN@30
31
32229µs263µs
# spent 35µs (7+28) within PPI::Token::DashedWord::BEGIN@32 which was called: # once (7µs+28µs) by PPI::Token::BEGIN@50 at line 32
use vars qw{$VERSION @ISA};
# spent 35µs making 1 call to PPI::Token::DashedWord::BEGIN@32 # spent 28µs making 1 call to vars::import
33
# spent 8µs within PPI::Token::DashedWord::BEGIN@33 which was called: # once (8µs+0s) by PPI::Token::BEGIN@50 at line 36
BEGIN {
341300ns $VERSION = '1.215';
3518µs @ISA = 'PPI::Token';
361146µs18µs}
# spent 8µs making 1 call to PPI::Token::DashedWord::BEGIN@33
37
38=pod
39
40=head2 literal
41
42Returns the value of the dashed word as a string. This differs from
43C<content> because C<-Foo'Bar> expands to C<-Foo::Bar>.
44
45=begin testing literal 9
46
47my @pairs = (
48 "-foo", '-foo',
49 "-Foo::Bar", '-Foo::Bar',
50 "-Foo'Bar", '-Foo::Bar',
51);
52while ( @pairs ) {
53 my $from = shift @pairs;
54 my $to = shift @pairs;
55 my $doc = PPI::Document->new( \"( $from => 1 );" );
56 isa_ok( $doc, 'PPI::Document' );
57 my $word = $doc->find_first('Token::DashedWord');
58 SKIP: {
59 skip( "PPI::Token::DashedWord is deactivated", 2 );
60 isa_ok( $word, 'PPI::Token::DashedWord' );
61 is( $word && $word->literal, $to, "The source $from becomes $to ok" );
62 }
63}
64
65=end testing
66
67=cut
68
691900ns*literal = *PPI::Token::Word::literal;
70
- -
73#####################################################################
74# Tokenizer Methods
75
76
# spent 69µs (40+28) within PPI::Token::DashedWord::__TOKENIZER__on_char which was called 2 times, avg 34µs/call: # 2 times (40µs+28µs) by PPI::Tokenizer::_process_next_char at line 554 of PPI/Tokenizer.pm, avg 34µs/call
sub __TOKENIZER__on_char {
772700ns my $t = $_[1];
78
79 # Suck to the end of the dashed bareword
8022µs my $line = substr( $t->{line}, $t->{line_cursor} );
81210µs22µs if ( $line =~ /^(\w+)/ ) {
# spent 2µs making 2 calls to PPI::Token::DashedWord::CORE:match, avg 800ns/call
82 $t->{token}->{content} .= $1;
83 $t->{line_cursor} += length $1;
84 }
85
86 # Are we a file test operator?
87213µs418µs if ( $t->{token}->{content} =~ /^\-[rwxoRWXOezsfdlpSbctugkTBMAC]$/ ) {
# spent 16µs making 2 calls to PPI::Token::set_class, avg 8µs/call # spent 2µs making 2 calls to PPI::Token::DashedWord::CORE:match, avg 950ns/call
88 # File test operator
89 $t->{class} = $t->{token}->set_class( 'Operator' );
90 } else {
91 # No, normal dashed bareword
92 $t->{class} = $t->{token}->set_class( 'Word' );
93 }
94
95210µs49µs $t->_finalize_token->__TOKENIZER__on_char( $t );
# spent 5µs making 2 calls to PPI::Tokenizer::_finalize_token, avg 2µs/call # spent 4µs making 2 calls to PPI::Token::Whitespace::__TOKENIZER__on_char, avg 2µs/call
96}
97
9812µs1;
99
100=pod
101
102=head1 SUPPORT
103
104See the L<support section|PPI/SUPPORT> in the main module.
105
106=head1 AUTHOR
107
108Adam Kennedy E<lt>adamk@cpan.orgE<gt>
109
110=head1 COPYRIGHT
111
112Copyright 2001 - 2011 Adam Kennedy.
113
114This program is free software; you can redistribute
115it and/or modify it under the same terms as Perl itself.
116
117The full text of the license can be found in the
118LICENSE file included with this module.
119
120=cut
 
# spent 4µs within PPI::Token::DashedWord::CORE:match which was called 4 times, avg 875ns/call: # 2 times (2µs+0s) by PPI::Token::DashedWord::__TOKENIZER__on_char at line 87, avg 950ns/call # 2 times (2µs+0s) by PPI::Token::DashedWord::__TOKENIZER__on_char at line 81, avg 800ns/call
sub PPI::Token::DashedWord::CORE:match; # opcode