← 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/Prototype.pm
StatementsExecuted 9 statements in 283µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs33µsPPI::Token::Prototype::::BEGIN@49PPI::Token::Prototype::BEGIN@49
11111µs11µsPPI::Token::Prototype::::BEGIN@53PPI::Token::Prototype::BEGIN@53
1119µs48µsPPI::Token::Prototype::::BEGIN@52PPI::Token::Prototype::BEGIN@52
1115µs5µsPPI::Token::Prototype::::BEGIN@50PPI::Token::Prototype::BEGIN@50
0000s0sPPI::Token::Prototype::::__TOKENIZER__on_charPPI::Token::Prototype::__TOKENIZER__on_char
0000s0sPPI::Token::Prototype::::prototypePPI::Token::Prototype::prototype
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::Prototype;
2
3=pod
4
5=head1 NAME
6
7PPI::Token::Prototype - A subroutine prototype descriptor
8
9=head1 INHERITANCE
10
11 PPI::Token::End
12 isa PPI::Token
13 isa PPI::Element
14
15=head1 SYNOPSIS
16
17 sub ($@) prototype;
18
19=head1 DESCRIPTION
20
21Although it sort of looks like a list or condition, a subroutine
22prototype is a lot more like a string. Its job is to provide hints
23to the perl compiler on what type of arguments a particular subroutine
24expects, which the compiler uses to validate parameters at compile-time,
25and allows programmers to use the functions without explicit parameter
26braces.
27
28Due to the rise of OO Perl coding, which ignores these prototypes, they
29are most often used to allow for constant-like things, and to "extend"
30the language and create things that act like keywords and core functions.
31
32 # Create something that acts like a constant
33 sub MYCONSTANT () { 10 }
34
35 # Create the "any" core-looking function
36 sub any (&@) { ... }
37
38 if ( any { $_->cute } @babies ) {
39 ...
40 }
41
42=head1 METHODS
43
44This class provides one additional method beyond those defined by the
45L<PPI::Token> and L<PPI::Element> parent classes.
46
47=cut
48
49226µs249µs
# spent 33µs (16+16) within PPI::Token::Prototype::BEGIN@49 which was called: # once (16µs+16µs) by PPI::Token::BEGIN@74 at line 49
use strict;
# spent 33µs making 1 call to PPI::Token::Prototype::BEGIN@49 # spent 16µs making 1 call to strict::import
50225µs15µs
# spent 5µs within PPI::Token::Prototype::BEGIN@50 which was called: # once (5µs+0s) by PPI::Token::BEGIN@74 at line 50
use PPI::Token ();
# spent 5µs making 1 call to PPI::Token::Prototype::BEGIN@50
51
52239µs286µs
# spent 48µs (9+39) within PPI::Token::Prototype::BEGIN@52 which was called: # once (9µs+39µs) by PPI::Token::BEGIN@74 at line 52
use vars qw{$VERSION @ISA};
# spent 48µs making 1 call to PPI::Token::Prototype::BEGIN@52 # spent 39µs making 1 call to vars::import
53
# spent 11µs within PPI::Token::Prototype::BEGIN@53 which was called: # once (11µs+0s) by PPI::Token::BEGIN@74 at line 56
BEGIN {
541500ns $VERSION = '1.215';
55111µs @ISA = 'PPI::Token';
561179µs111µs}
# spent 11µs making 1 call to PPI::Token::Prototype::BEGIN@53
57
58sub __TOKENIZER__on_char {
59 my $class = shift;
60 my $t = shift;
61
62 # Suck in until we find the closing bracket (or the end of line)
63 my $line = substr( $t->{line}, $t->{line_cursor} );
64 if ( $line =~ /^(.*?(?:\)|$))/ ) {
65 $t->{token}->{content} .= $1;
66 $t->{line_cursor} += length $1;
67 }
68
69 # Shortcut if end of line
70 return 0 unless $1 =~ /\)$/;
71
72 # Found the closing bracket
73 $t->_finalize_token->__TOKENIZER__on_char( $t );
74}
75
76=pod
77
78=head2 prototype
79
80The C<prototype> accessor returns the actual prototype pattern, stripped
81of braces and any whitespace inside the pattern.
82
83=cut
84
85sub prototype {
86 my $self = shift;
87 my $proto = $self->content;
88 $proto =~ s/\(\)\s//g; # Strip brackets and whitespace
89 $proto;
90}
91
9212µs1;
93
94=pod
95
96=head1 SUPPORT
97
98See the L<support section|PPI/SUPPORT> in the main module.
99
100=head1 AUTHOR
101
102Adam Kennedy E<lt>adamk@cpan.orgE<gt>
103
104=head1 COPYRIGHT
105
106Copyright 2001 - 2011 Adam Kennedy.
107
108This program is free software; you can redistribute
109it and/or modify it under the same terms as Perl itself.
110
111The full text of the license can be found in the
112LICENSE file included with this module.
113
114=cut