← 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/darwin-2level/HTML/Parser.pm
StatementsExecuted 14 statements in 922µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11113µs26µsHTML::Parser::::BEGIN@9HTML::Parser::BEGIN@9
1117µs36µsHTML::Parser::::BEGIN@10HTML::Parser::BEGIN@10
0000s0sHTML::Parser::::__ANON__[:54]HTML::Parser::__ANON__[:54]
0000s0sHTML::Parser::::__ANON__[:60]HTML::Parser::__ANON__[:60]
0000s0sHTML::Parser::::initHTML::Parser::init
0000s0sHTML::Parser::::netscape_buggy_commentHTML::Parser::netscape_buggy_comment
0000s0sHTML::Parser::::newHTML::Parser::new
0000s0sHTML::Parser::::parse_fileHTML::Parser::parse_file
0000s0sHTML::Parser::::textHTML::Parser::text
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package HTML::Parser;
2
3# Copyright 1996-2009, Gisle Aas.
4# Copyright 1999-2000, Michael A. Chase.
5#
6# This library is free software; you can redistribute it and/or
7# modify it under the same terms as Perl itself.
8
9227µs239µs
# spent 26µs (13+13) within HTML::Parser::BEGIN@9 which was called: # once (13µs+13µs) by Perl::Tidy::HtmlWriter::BEGIN@2 at line 9
use strict;
# spent 26µs making 1 call to HTML::Parser::BEGIN@9 # spent 13µs making 1 call to strict::import
102506µs265µs
# spent 36µs (7+29) within HTML::Parser::BEGIN@10 which was called: # once (7µs+29µs) by Perl::Tidy::HtmlWriter::BEGIN@2 at line 10
use vars qw($VERSION @ISA);
# spent 36µs making 1 call to HTML::Parser::BEGIN@10 # spent 29µs making 1 call to vars::import
11
121600ns$VERSION = "3.71";
13
141300nsrequire HTML::Entities;
15
161800nsrequire XSLoader;
171379µs1371µsXSLoader::load('HTML::Parser', $VERSION);
# spent 371µs making 1 call to XSLoader::load
18
19sub new
20{
21 my $class = shift;
22 my $self = bless {}, $class;
23 return $self->init(@_);
24}
25
26
27sub init
28{
29 my $self = shift;
30 $self->_alloc_pstate;
31
32 my %arg = @_;
33 my $api_version = delete $arg{api_version} || (@_ ? 3 : 2);
34 if ($api_version >= 4) {
35 require Carp;
36 Carp::croak("API version $api_version not supported " .
37 "by HTML::Parser $VERSION");
38 }
39
40 if ($api_version < 3) {
41 # Set up method callbacks compatible with HTML-Parser-2.xx
42 $self->handler(text => "text", "self,text,is_cdata");
43 $self->handler(end => "end", "self,tagname,text");
44 $self->handler(process => "process", "self,token0,text");
45 $self->handler(start => "start",
46 "self,tagname,attr,attrseq,text");
47
48 $self->handler(comment =>
49 sub {
50 my($self, $tokens) = @_;
51 for (@$tokens) {
52 $self->comment($_);
53 }
54 }, "self,tokens");
55
56 $self->handler(declaration =>
57 sub {
58 my $self = shift;
59 $self->declaration(substr($_[0], 2, -1));
60 }, "self,text");
61 }
62
63 if (my $h = delete $arg{handlers}) {
64 $h = {@$h} if ref($h) eq "ARRAY";
65 while (my($event, $cb) = each %$h) {
66 $self->handler($event => @$cb);
67 }
68 }
69
70 # In the end we try to assume plain attribute or handler
71 while (my($option, $val) = each %arg) {
72 if ($option =~ /^(\w+)_h$/) {
73 $self->handler($1 => @$val);
74 }
75 elsif ($option =~ /^(text|start|end|process|declaration|comment)$/) {
76 require Carp;
77 Carp::croak("Bad constructor option '$option'");
78 }
79 else {
80 $self->$option($val);
81 }
82 }
83
84 return $self;
85}
86
87
88sub parse_file
89{
90 my($self, $file) = @_;
91 my $opened;
92 if (!ref($file) && ref(\$file) ne "GLOB") {
93 # Assume $file is a filename
94 local(*F);
95 open(F, "<", $file) || return undef;
96 binmode(F); # should we? good for byte counts
97 $opened++;
98 $file = *F;
99 }
100 my $chunk = '';
101 while (read($file, $chunk, 512)) {
102 $self->parse($chunk) || last;
103 }
104 close($file) if $opened;
105 $self->eof;
106}
107
108
109sub netscape_buggy_comment # legacy
110{
111 my $self = shift;
112 require Carp;
113 Carp::carp("netscape_buggy_comment() is deprecated. " .
114 "Please use the strict_comment() method instead");
115 my $old = !$self->strict_comment;
116 $self->strict_comment(!shift) if @_;
117 return $old;
118}
119
120# set up method stubs
121sub text { }
12211µs*start = \&text;
1231200ns*end = \&text;
1241200ns*comment = \&text;
1251100ns*declaration = \&text;
1261100ns*process = \&text;
127
12815µs1;
129
130__END__