← 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/Quote/Single.pm
StatementsExecuted 20 statements in 388µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111218µs47.5msPPI::Token::Quote::Single::::BEGIN@38PPI::Token::Quote::Single::BEGIN@38
41118µs18µsPPI::Token::Quote::Single::::stringPPI::Token::Quote::Single::string
11113µs13µsPPI::Token::Quote::Single::::BEGIN@42PPI::Token::Quote::Single::BEGIN@42
11111µs22µsPPI::Token::Quote::Single::::BEGIN@37PPI::Token::Quote::Single::BEGIN@37
1118µs52µsPPI::Token::Quote::Single::::BEGIN@41PPI::Token::Quote::Single::BEGIN@41
1115µs5µsPPI::Token::Quote::Single::::BEGIN@39PPI::Token::Quote::Single::BEGIN@39
0000s0sPPI::Token::Quote::Single::::literalPPI::Token::Quote::Single::literal
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::Quote::Single;
2
3=pod
4
5=head1 NAME
6
7PPI::Token::Quote::Single - A 'single quote' token
8
9=head1 INHERITANCE
10
11 PPI::Token::Quote::Single
12 isa PPI::Token::Quote
13 isa PPI::Token
14 isa PPI::Element
15
16=head1 SYNOPSIS
17
18 'This is a single quote'
19
20 q{This is a literal, but NOT a single quote}
21
22=head1 DESCRIPTION
23
24A C<PPI::Token::Quote::Single> object represents a single quoted string
25literal.
26
27=head1 METHODS
28
29There are no methods available for C<PPI::Token::Quote::Single> beyond
30those provided by the parent L<PPI::Token::Quote>, L<PPI::Token> and
31L<PPI::Element> classes.
32
33Got any ideas for methods? Submit a report to rt.cpan.org!
34
35=cut
36
37218µs234µs
# spent 22µs (11+12) within PPI::Token::Quote::Single::BEGIN@37 which was called: # once (11µs+12µs) by Perl::Critic::Utils::BEGIN@23 at line 37
use strict;
# spent 22µs making 1 call to PPI::Token::Quote::Single::BEGIN@37 # spent 12µs making 1 call to strict::import
38294µs147.5ms
# spent 47.5ms (218µs+47.3) within PPI::Token::Quote::Single::BEGIN@38 which was called: # once (218µs+47.3ms) by Perl::Critic::Utils::BEGIN@23 at line 38
use PPI::Token::Quote ();
# spent 47.5ms making 1 call to PPI::Token::Quote::Single::BEGIN@38
39227µs15µs
# spent 5µs within PPI::Token::Quote::Single::BEGIN@39 which was called: # once (5µs+0s) by Perl::Critic::Utils::BEGIN@23 at line 39
use PPI::Token::_QuoteEngine::Simple ();
# spent 5µs making 1 call to PPI::Token::Quote::Single::BEGIN@39
40
41242µs296µs
# spent 52µs (8+44) within PPI::Token::Quote::Single::BEGIN@41 which was called: # once (8µs+44µs) by Perl::Critic::Utils::BEGIN@23 at line 41
use vars qw{$VERSION @ISA};
# spent 52µs making 1 call to PPI::Token::Quote::Single::BEGIN@41 # spent 44µs making 1 call to vars::import
42
# spent 13µs within PPI::Token::Quote::Single::BEGIN@42 which was called: # once (13µs+0s) by Perl::Critic::Utils::BEGIN@23 at line 48
BEGIN {
431500ns $VERSION = '1.215';
44113µs @ISA = qw{
45 PPI::Token::_QuoteEngine::Simple
46 PPI::Token::Quote
47 };
481164µs113µs}
# spent 13µs making 1 call to PPI::Token::Quote::Single::BEGIN@42
49
- -
54#####################################################################
55# PPI::Token::Quote Methods
56
57=pod
58
59=begin testing string 3
60
61my $Document = PPI::Document->new( \"print 'foo';" );
62isa_ok( $Document, 'PPI::Document' );
63my $Single = $Document->find_first('Token::Quote::Single');
64isa_ok( $Single, 'PPI::Token::Quote::Single' );
65is( $Single->string, 'foo', '->string returns as expected' );
66
67=end testing
68
69=cut
70
71
# spent 18µs within PPI::Token::Quote::Single::string which was called 4 times, avg 4µs/call: # 4 times (18µs+0s) by Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_get_argument_string at line 68 of Perl/Critic/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm, avg 4µs/call
sub string {
7244µs my $str = $_[0]->{content};
73417µs substr( $str, 1, length($str) - 2 );
74}
75
76=pod
77
78=begin testing literal 21
79
80my @pairs = (
81 "''", '',
82 "'f'", 'f',
83 "'f\\'b'", "f\'b",
84 "'f\\nb'", "f\\nb",
85 "'f\\\\b'", "f\\b",
86 "'f\\\\\\b'", "f\\\\b",
87 "'f\\\\\\\''", "f\\'",
88);
89while ( @pairs ) {
90 my $from = shift @pairs;
91 my $to = shift @pairs;
92 my $doc = PPI::Document->new( \"print $from;" );
93 isa_ok( $doc, 'PPI::Document' );
94 my $quote = $doc->find_first('Token::Quote::Single');
95 isa_ok( $quote, 'PPI::Token::Quote::Single' );
96 is( $quote->literal, $to, "The source $from becomes $to ok" );
97}
98
99=end testing
100
101=cut
102
10313µsmy %UNESCAPE = (
104 "\\'" => "'",
105 "\\\\" => "\\",
106);
107
108sub literal {
109 # Unescape \\ and \' ONLY
110 my $str = $_[0]->string;
111 $str =~ s/(\\.)/$UNESCAPE{$1} || $1/ge;
112 return $str;
113}
114
11514µs1;
116
117=pod
118
119=head1 SUPPORT
120
121See the L<support section|PPI/SUPPORT> in the main module.
122
123=head1 AUTHOR
124
125Adam Kennedy E<lt>adamk@cpan.orgE<gt>
126
127=head1 COPYRIGHT
128
129Copyright 2001 - 2011 Adam Kennedy.
130
131This program is free software; you can redistribute
132it and/or modify it under the same terms as Perl itself.
133
134The full text of the license can be found in the
135LICENSE file included with this module.
136
137=cut