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

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Token/Assertion.pm
StatementsExecuted 14 statements in 264µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs23µsPPIx::Regexp::Token::Assertion::::BEGIN@34PPIx::Regexp::Token::Assertion::BEGIN@34
1117µs33µsPPIx::Regexp::Token::Assertion::::BEGIN@39PPIx::Regexp::Token::Assertion::BEGIN@39
1116µs11µsPPIx::Regexp::Token::Assertion::::BEGIN@35PPIx::Regexp::Token::Assertion::BEGIN@35
1116µs67µsPPIx::Regexp::Token::Assertion::::BEGIN@37PPIx::Regexp::Token::Assertion::BEGIN@37
0000s0sPPIx::Regexp::Token::Assertion::::__PPIX_TOKENIZER__regexpPPIx::Regexp::Token::Assertion::__PPIX_TOKENIZER__regexp
0000s0sPPIx::Regexp::Token::Assertion::::perl_version_introducedPPIx::Regexp::Token::Assertion::perl_version_introduced
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1=head1 NAME
2
3PPIx::Regexp::Token::Assertion - Represent a simple assertion.
4
5=head1 SYNOPSIS
6
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'qr{\bfoo\b}smx' )
9 ->print();
10
11=head1 INHERITANCE
12
13C<PPIx::Regexp::Token::Assertion> is a
14L<PPIx::Regexp::Token|PPIx::Regexp::Token>.
15
16C<PPIx::Regexp::Token::Assertion> has no descendants.
17
18=head1 DESCRIPTION
19
20This class represents one of the simple assertions; that is, those that
21are not defined via parentheses. This includes the zero-width assertions
22C<^>, C<$>, C<\b>, C<\B>, C<\A>, C<\Z>, C<\z> and C<\G>, as well as the
23positive look-behind assertion C<\K> added in Perl 5.009005.
24
25=head1 METHODS
26
27This class provides no public methods beyond those provided by its
28superclass.
29
30=cut
31
32package PPIx::Regexp::Token::Assertion;
33
34219µs235µs
# spent 23µs (12+12) within PPIx::Regexp::Token::Assertion::BEGIN@34 which was called: # once (12µs+12µs) by PPIx::Regexp::Tokenizer::BEGIN@14 at line 34
use strict;
# spent 23µs making 1 call to PPIx::Regexp::Token::Assertion::BEGIN@34 # spent 12µs making 1 call to strict::import
35224µs215µs
# spent 11µs (6+4) within PPIx::Regexp::Token::Assertion::BEGIN@35 which was called: # once (6µs+4µs) by PPIx::Regexp::Tokenizer::BEGIN@14 at line 35
use warnings;
# spent 11µs making 1 call to PPIx::Regexp::Token::Assertion::BEGIN@35 # spent 4µs making 1 call to warnings::import
36
37226µs2128µs
# spent 67µs (6+61) within PPIx::Regexp::Token::Assertion::BEGIN@37 which was called: # once (6µs+61µs) by PPIx::Regexp::Tokenizer::BEGIN@14 at line 37
use base qw{ PPIx::Regexp::Token };
# spent 67µs making 1 call to PPIx::Regexp::Token::Assertion::BEGIN@37 # spent 61µs making 1 call to base::import
38
392180µs259µs
# spent 33µs (7+26) within PPIx::Regexp::Token::Assertion::BEGIN@39 which was called: # once (7µs+26µs) by PPIx::Regexp::Tokenizer::BEGIN@14 at line 39
use PPIx::Regexp::Constant qw{ COOKIE_CLASS MINIMUM_PERL TOKEN_LITERAL };
# spent 33µs making 1 call to PPIx::Regexp::Token::Assertion::BEGIN@39 # spent 26µs making 1 call to Exporter::import
40
411600nsour $VERSION = '0.036';
42
43# Return true if the token can be quantified, and false otherwise
44# sub can_be_quantified { return };
45
46{
47
4822µs my %perl_version_introduced = (
49 '\\K' => '5.009005',
50 '\\z' => '5.005',
51 );
52
53 sub perl_version_introduced {
54 my ( $self ) = @_;
55 return $perl_version_introduced{$self->content()} || MINIMUM_PERL;
56 }
57
58}
59
60# By logic we should handle '$' here. But
61# PPIx::Regexp::Token::Interpolation needs to process it to see if it is
62# a sigil. If it is not, that module is expected to make it into an
63# assertion. This is to try to keep the order in which the tokenizers
64# are called non-critical, and try to keep all processing for a
65# character in one place. Except for the back slash, which gets in
66# everywhere.
67#
68## my %assertion = map { $_ => 1 } qw{ ^ $ };
6912µsmy %assertion = map { $_ => 1 } qw{ ^ };
7015µsmy %escaped = map { $_ => 1 } qw{ b B A Z z G K };
71
72sub __PPIX_TOKENIZER__regexp {
73 my ( $class, $tokenizer, $character ) = @_;
74
75 # Inside a character class, these are all literals.
76 my $make = $tokenizer->cookie( COOKIE_CLASS ) ?
77 TOKEN_LITERAL :
78 __PACKAGE__;
79
80 # '^' and '$'. Or at least '^'. See note above for '$'.
81 $assertion{$character}
82 and return $tokenizer->make_token( 1, $make );
83
84 $character eq '\\' or return;
85
86 defined ( my $next = $tokenizer->peek( 1 ) ) or return;
87
88 $escaped{$next}
89 and return $tokenizer->make_token( 2, $make );
90
91 return;
92}
93
9415µs1;
95
96__END__