← Index
NYTProf Performance Profile   « line view »
For t/bug-md-11.t
  Run on Fri Mar 8 13:27:24 2024
Reported on Fri Mar 8 13:30:23 2024

Filename/home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/x86_64-linux/XML/Parser/Expat.pm
StatementsExecuted 21950262 statements in 19.7s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
67598523.07s3.36sXML::Parser::Expat::::setHandlers XML::Parser::Expat::setHandlers
7112.57s70.4sXML::Parser::Expat::::ParseString XML::Parser::Expat::ParseString (xsub)
1460048211.73s1.73sXML::Parser::Expat::::namespace XML::Parser::Expat::namespace
380001111.51s1.51sXML::Parser::Expat::::current_ns_prefixes XML::Parser::Expat::current_ns_prefixes
1520689211.31s1.31sXML::Parser::Expat::::expand_ns_prefix XML::Parser::Expat::expand_ns_prefix
364369111.09s1.31sXML::Parser::Expat::::recognized_string XML::Parser::Expat::recognized_string
39816711243ms243msXML::Parser::Expat::::new_ns_prefixes XML::Parser::Expat::new_ns_prefixes
36436911223ms223msXML::Parser::Expat::::RecognizedString XML::Parser::Expat::RecognizedString (xsub)
43158151221ms221msXML::Parser::Expat::::depth XML::Parser::Expat::depth
675911126.8ms26.8msXML::Parser::Expat::::SetXMLDeclHandler XML::Parser::Expat::SetXMLDeclHandler (xsub)
675911122.2ms22.2msXML::Parser::Expat::::SetEndElementHandler XML::Parser::Expat::SetEndElementHandler (xsub)
675911121.1ms21.1msXML::Parser::Expat::::SetEntityDeclHandler XML::Parser::Expat::SetEntityDeclHandler (xsub)
675911120.8ms20.8msXML::Parser::Expat::::SetAttListDeclHandler XML::Parser::Expat::SetAttListDeclHandler (xsub)
675911120.5ms20.5msXML::Parser::Expat::::SetCommentHandler XML::Parser::Expat::SetCommentHandler (xsub)
675911120.4ms20.4msXML::Parser::Expat::::SetCharacterDataHandler XML::Parser::Expat::SetCharacterDataHandler (xsub)
675911120.2ms20.2msXML::Parser::Expat::::SetEndCdataHandler XML::Parser::Expat::SetEndCdataHandler (xsub)
675911120.1ms20.1msXML::Parser::Expat::::SetExternalEntityRefHandler XML::Parser::Expat::SetExternalEntityRefHandler (xsub)
675911119.4ms19.4msXML::Parser::Expat::::SetElementDeclHandler XML::Parser::Expat::SetElementDeclHandler (xsub)
675911118.9ms18.9msXML::Parser::Expat::::SetStartCdataHandler XML::Parser::Expat::SetStartCdataHandler (xsub)
675911117.8ms17.8msXML::Parser::Expat::::SetDoctypeHandler XML::Parser::Expat::SetDoctypeHandler (xsub)
675911117.8ms17.8msXML::Parser::Expat::::SetProcessingInstructionHandler XML::Parser::Expat::SetProcessingInstructionHandler (xsub)
675981117.4ms17.4msXML::Parser::Expat::::SetDefaultHandler XML::Parser::Expat::SetDefaultHandler (xsub)
675911115.7ms15.7msXML::Parser::Expat::::SetStartElementHandler XML::Parser::Expat::SetStartElementHandler (xsub)
71112.0ms70.4sXML::Parser::Expat::::parse XML::Parser::Expat::parse
337981110.5ms10.5msXML::Parser::Expat::::SetNotationDeclHandler XML::Parser::Expat::SetNotationDeclHandler (xsub)
711616µs616µsXML::Parser::Expat::::ParserFree XML::Parser::Expat::ParserFree (xsub)
71179µs126µsXML::Parser::Expat::::new XML::Parser::Expat::new
281166µs66µsXML::Parser::Expat::::NamespaceStart XML::Parser::Expat::NamespaceStart
71147µs47µsXML::Parser::Expat::::ParserCreate XML::Parser::Expat::ParserCreate (xsub)
281141µs41µsXML::Parser::Expat::::NamespaceEnd XML::Parser::Expat::NamespaceEnd
71115µs632µsXML::Parser::Expat::::DESTROY XML::Parser::Expat::DESTROY
71115µs18µsXML::Parser::Expat::::release XML::Parser::Expat::release
11110µs25µsXML::Parser::ContentModel::::BEGIN@512XML::Parser::ContentModel::BEGIN@512
1118µs10µsXML::Parser::Expat::::BEGIN@3 XML::Parser::Expat::BEGIN@3
1118µs9µsXML::Parser::Expat::::BEGIN@7 XML::Parser::Expat::BEGIN@7
1117µs14µsXML::Parser::Expat::::BEGIN@460 XML::Parser::Expat::BEGIN@460
1115µs27µsXML::Parser::ExpatNB::::BEGIN@600 XML::Parser::ExpatNB::BEGIN@600
7113µs3µsXML::Parser::Expat::::ParserRelease XML::Parser::Expat::ParserRelease (xsub)
1113µs21µsXML::Parser::Expat::::BEGIN@8 XML::Parser::Expat::BEGIN@8
1112µs2µsXML::Parser::Expat::::BEGIN@14 XML::Parser::Expat::BEGIN@14
0000s0sXML::Parser::ContentModel::::asStringXML::Parser::ContentModel::asString
0000s0sXML::Parser::ContentModel::::childrenXML::Parser::ContentModel::children
0000s0sXML::Parser::ContentModel::::isanyXML::Parser::ContentModel::isany
0000s0sXML::Parser::ContentModel::::ischoiceXML::Parser::ContentModel::ischoice
0000s0sXML::Parser::ContentModel::::isemptyXML::Parser::ContentModel::isempty
0000s0sXML::Parser::ContentModel::::ismixedXML::Parser::ContentModel::ismixed
0000s0sXML::Parser::ContentModel::::isnameXML::Parser::ContentModel::isname
0000s0sXML::Parser::ContentModel::::isseqXML::Parser::ContentModel::isseq
0000s0sXML::Parser::ContentModel::::nameXML::Parser::ContentModel::name
0000s0sXML::Parser::ContentModel::::quantXML::Parser::ContentModel::quant
0000s0sXML::Parser::ContentModel::::thiseqXML::Parser::ContentModel::thiseq
0000s0sXML::Parser::Encinfo::::DESTROY XML::Parser::Encinfo::DESTROY
0000s0sXML::Parser::Expat::::base XML::Parser::Expat::base
0000s0sXML::Parser::Expat::::context XML::Parser::Expat::context
0000s0sXML::Parser::Expat::::current_byte XML::Parser::Expat::current_byte
0000s0sXML::Parser::Expat::::current_column XML::Parser::Expat::current_column
0000s0sXML::Parser::Expat::::current_element XML::Parser::Expat::current_element
0000s0sXML::Parser::Expat::::current_line XML::Parser::Expat::current_line
0000s0sXML::Parser::Expat::::default_current XML::Parser::Expat::default_current
0000s0sXML::Parser::Expat::::element_index XML::Parser::Expat::element_index
0000s0sXML::Parser::Expat::::eq_name XML::Parser::Expat::eq_name
0000s0sXML::Parser::Expat::::finish XML::Parser::Expat::finish
0000s0sXML::Parser::Expat::::generate_ns_name XML::Parser::Expat::generate_ns_name
0000s0sXML::Parser::Expat::::in_element XML::Parser::Expat::in_element
0000s0sXML::Parser::Expat::::load_encoding XML::Parser::Expat::load_encoding
0000s0sXML::Parser::Expat::::original_string XML::Parser::Expat::original_string
0000s0sXML::Parser::Expat::::parsefile XML::Parser::Expat::parsefile
0000s0sXML::Parser::Expat::::parsestring XML::Parser::Expat::parsestring
0000s0sXML::Parser::Expat::::position_in_context XML::Parser::Expat::position_in_context
0000s0sXML::Parser::Expat::::skip_until XML::Parser::Expat::skip_until
0000s0sXML::Parser::Expat::::specified_attr XML::Parser::Expat::specified_attr
0000s0sXML::Parser::Expat::::within_element XML::Parser::Expat::within_element
0000s0sXML::Parser::Expat::::xml_escape XML::Parser::Expat::xml_escape
0000s0sXML::Parser::Expat::::xpcarp XML::Parser::Expat::xpcarp
0000s0sXML::Parser::Expat::::xpcroak XML::Parser::Expat::xpcroak
0000s0sXML::Parser::ExpatNB::::parse XML::Parser::ExpatNB::parse
0000s0sXML::Parser::ExpatNB::::parse_done XML::Parser::ExpatNB::parse_done
0000s0sXML::Parser::ExpatNB::::parse_more XML::Parser::ExpatNB::parse_more
0000s0sXML::Parser::ExpatNB::::parsefile XML::Parser::ExpatNB::parsefile
0000s0sXML::Parser::ExpatNB::::parsestring XML::Parser::ExpatNB::parsestring
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package XML::Parser::Expat;
2
3217µs211µs
# spent 10µs (8+1) within XML::Parser::Expat::BEGIN@3 which was called: # once (8µs+1µs) by XML::Parser::BEGIN@17 at line 3
use strict;
# spent 10µs making 1 call to XML::Parser::Expat::BEGIN@3 # spent 1µs making 1 call to strict::import
4
5#use warnings; No warnings numeric??
6
7213µs29µs
# spent 9µs (8+700ns) within XML::Parser::Expat::BEGIN@7 which was called: # once (8µs+700ns) by XML::Parser::BEGIN@17 at line 7
use XSLoader;
# spent 9µs making 1 call to XML::Parser::Expat::BEGIN@7 # spent 700ns making 1 call to UNIVERSAL::import
8234µs239µs
# spent 21µs (3+18) within XML::Parser::Expat::BEGIN@8 which was called: # once (3µs+18µs) by XML::Parser::BEGIN@17 at line 8
use Carp;
# spent 21µs making 1 call to XML::Parser::Expat::BEGIN@8 # spent 18µs making 1 call to Exporter::import
9
101300nsour $VERSION = '2.47';
11
12our ( %Encoding_Table, @Encoding_Path, $have_File_Spec );
13
1421.37ms12µs
# spent 2µs within XML::Parser::Expat::BEGIN@14 which was called: # once (2µs+0s) by XML::Parser::BEGIN@17 at line 14
use File::Spec ();
# spent 2µs making 1 call to XML::Parser::Expat::BEGIN@14
15
161300ns%Encoding_Table = ();
171500nsif ($have_File_Spec) {
18 @Encoding_Path = (
19 grep( -d $_,
20 map( File::Spec->catdir( $_, qw(XML Parser Encodings) ),
21 @INC ) ),
22 File::Spec->curdir
23 );
24}
25else {
26124µs512µs @Encoding_Path = ( grep( -d $_, map( $_ . '/XML/Parser/Encodings', @INC ) ), '.' );
# spent 12µs making 5 calls to CORE::ftdir, avg 2µs/call
27}
28
291208µs1202µsXSLoader::load( 'XML::Parser::Expat', $VERSION );
# spent 202µs making 1 call to XSLoader::load
30
3114µsour %Handler_Setters = (
32 Start => \&SetStartElementHandler,
33 End => \&SetEndElementHandler,
34 Char => \&SetCharacterDataHandler,
35 Proc => \&SetProcessingInstructionHandler,
36 Comment => \&SetCommentHandler,
37 CdataStart => \&SetStartCdataHandler,
38 CdataEnd => \&SetEndCdataHandler,
39 Default => \&SetDefaultHandler,
40 Unparsed => \&SetUnparsedEntityDeclHandler,
41 Notation => \&SetNotationDeclHandler,
42 ExternEnt => \&SetExternalEntityRefHandler,
43 ExternEntFin => \&SetExtEntFinishHandler,
44 Entity => \&SetEntityDeclHandler,
45 Element => \&SetElementDeclHandler,
46 Attlist => \&SetAttListDeclHandler,
47 Doctype => \&SetDoctypeHandler,
48 DoctypeFin => \&SetEndDoctypeHandler,
49 XMLDecl => \&SetXMLDeclHandler
50);
51
52
# spent 126µs (79+47) within XML::Parser::Expat::new which was called 7 times, avg 18µs/call: # 7 times (79µs+47µs) by XML::Parser::parse at line 171 of XML/Parser.pm, avg 18µs/call
sub new {
53725µs my ( $class, %args ) = @_;
5474µs my $self = bless \%args, $_[0];
5572µs $args{_State_} = 0;
5673µs $args{Context} = [];
5772µs $args{Namespaces} ||= 0;
5872µs $args{ErrorMessage} ||= '';
5973µs if ( $args{Namespaces} ) {
6072µs $args{Namespace_Table} = {};
6173µs $args{Namespace_List} = [undef];
6273µs $args{Prefix_Table} = {};
6372µs $args{New_Prefixes} = [];
64 }
6572µs $args{_Setters} = \%Handler_Setters;
66 $args{Parser} = ParserCreate(
67 $self, $args{ProtocolEncoding},
68 $args{Namespaces}
69766µs747µs );
# spent 47µs making 7 calls to XML::Parser::Expat::ParserCreate, avg 7µs/call
7078µs $self;
71}
72
73sub load_encoding {
74 my ($file) = @_;
75
76 $file =~ s!([^/]+)$!\L$1\E!;
77 $file .= '.enc' unless $file =~ /\.enc$/;
78 unless ( $file =~ m!^/! ) {
79 foreach (@Encoding_Path) {
80 my $tmp = (
81 $have_File_Spec
82 ? File::Spec->catfile( $_, $file )
83 : "$_/$file"
84 );
85 if ( -e $tmp ) {
86 $file = $tmp;
87 last;
88 }
89 }
90 }
91
92 open( my $fh, '<', $file ) or croak("Couldn't open encmap $file:\n$!\n");
93 binmode($fh);
94 my $data;
95 my $br = sysread( $fh, $data, -s $file );
96 croak("Trouble reading $file:\n$!\n")
97 unless defined($br);
98 close($fh);
99
100 my $name = LoadEncoding( $data, $br );
101 croak("$file isn't an encmap file")
102 unless defined($name);
103
104 $name;
105} # End load_encoding
106
107
# spent 3.36s (3.07+290ms) within XML::Parser::Expat::setHandlers which was called 67598 times, avg 50µs/call: # 33792 times (1.56s+140ms) by XML::Twig::_twig_start_check_roots at line 4144 of XML/Twig.pm, avg 50µs/call # 33792 times (1.51s+150ms) by XML::Twig::_twig_end at line 2371 of XML/Twig.pm, avg 49µs/call # 7 times (218µs+44µs) by XML::Parser::parse at line 176 of XML/Parser.pm, avg 38µs/call # 6 times (26µs+4µs) by XML::Twig::_twig_start at line 2117 of XML/Twig.pm, avg 5µs/call # once (8µs+900ns) by XML::Twig::_twig_start at line 2112 of XML/Twig.pm
sub setHandlers {
1086759890.9ms my ( $self, @handler_pairs ) = @_;
109
1106759819.7ms croak("Uneven number of arguments to setHandlers method")
111 if ( int(@handler_pairs) & 1 );
112
113675986.83ms my @ret;
114
1156759814.7ms while (@handler_pairs) {
116980079107ms my $type = shift @handler_pairs;
11798007984.3ms my $handler = shift @handler_pairs;
118980079141ms croak 'Handler for $type not a Code ref'
119 unless ( !defined($handler) or !$handler or ref($handler) eq 'CODE' );
120
121980079152ms my $hndl = $self->{_Setters}->{$type};
122
12398007964.9ms unless ( defined($hndl) ) {
124 my @types = sort keys %{ $self->{_Setters} };
125 croak("Unknown Expat handler type: $type\n Valid types: @types");
126 }
127
1289800792.30s980079290ms my $old = &$hndl( $self->{Parser}, $handler );
# spent 26.8ms making 67591 calls to XML::Parser::Expat::SetXMLDeclHandler, avg 396ns/call # spent 22.2ms making 67591 calls to XML::Parser::Expat::SetEndElementHandler, avg 329ns/call # spent 21.1ms making 67591 calls to XML::Parser::Expat::SetEntityDeclHandler, avg 312ns/call # spent 20.8ms making 67591 calls to XML::Parser::Expat::SetAttListDeclHandler, avg 308ns/call # spent 20.5ms making 67591 calls to XML::Parser::Expat::SetCommentHandler, avg 303ns/call # spent 20.4ms making 67591 calls to XML::Parser::Expat::SetCharacterDataHandler, avg 301ns/call # spent 20.2ms making 67591 calls to XML::Parser::Expat::SetEndCdataHandler, avg 299ns/call # spent 20.1ms making 67591 calls to XML::Parser::Expat::SetExternalEntityRefHandler, avg 298ns/call # spent 19.4ms making 67591 calls to XML::Parser::Expat::SetElementDeclHandler, avg 287ns/call # spent 18.9ms making 67591 calls to XML::Parser::Expat::SetStartCdataHandler, avg 279ns/call # spent 17.8ms making 67591 calls to XML::Parser::Expat::SetDoctypeHandler, avg 264ns/call # spent 17.8ms making 67591 calls to XML::Parser::Expat::SetProcessingInstructionHandler, avg 263ns/call # spent 17.4ms making 67598 calls to XML::Parser::Expat::SetDefaultHandler, avg 258ns/call # spent 15.7ms making 67591 calls to XML::Parser::Expat::SetStartElementHandler, avg 232ns/call # spent 10.5ms making 33798 calls to XML::Parser::Expat::SetNotationDeclHandler, avg 310ns/call
129980079313ms push( @ret, $type, $old );
130 }
131
13267598173ms return @ret;
133}
134
135sub xpcroak {
136 my ( $self, $message ) = @_;
137
138 my $eclines = $self->{ErrorContext};
139 my $line = GetCurrentLineNumber( $_[0]->{Parser} );
140 $message .= " at line $line";
141 $message .= ":\n" . $self->position_in_context($eclines)
142 if defined($eclines);
143 croak $message;
144}
145
146sub xpcarp {
147 my ( $self, $message ) = @_;
148
149 my $eclines = $self->{ErrorContext};
150 my $line = GetCurrentLineNumber( $_[0]->{Parser} );
151 $message .= ' at line $line';
152 $message .= ":\n" . $self->position_in_context($eclines)
153 if defined($eclines);
154 carp $message;
155}
156
157sub default_current {
158 my $self = shift;
159 if ( $self->{_State_} == 1 ) {
160 return DefaultCurrent( $self->{Parser} );
161 }
162}
163
164
# spent 1.31s (1.09+223ms) within XML::Parser::Expat::recognized_string which was called 364369 times, avg 4µs/call: # 364369 times (1.09s+223ms) by XML::Twig::_twig_start at line 2120 of XML/Twig.pm, avg 4µs/call
sub recognized_string {
16536436938.6ms my $self = shift;
1663643691.98s364369223ms if ( $self->{_State_} == 1 ) {
# spent 223ms making 364369 calls to XML::Parser::Expat::RecognizedString, avg 613ns/call
167 return RecognizedString( $self->{Parser} );
168 }
169}
170
171sub original_string {
172 my $self = shift;
173 if ( $self->{_State_} == 1 ) {
174 return OriginalString( $self->{Parser} );
175 }
176}
177
178sub current_line {
179 my $self = shift;
180 if ( $self->{_State_} == 1 ) {
181 return GetCurrentLineNumber( $self->{Parser} );
182 }
183}
184
185sub current_column {
186 my $self = shift;
187 if ( $self->{_State_} == 1 ) {
188 return GetCurrentColumnNumber( $self->{Parser} );
189 }
190}
191
192sub current_byte {
193 my $self = shift;
194 if ( $self->{_State_} == 1 ) {
195 return GetCurrentByteIndex( $self->{Parser} );
196 }
197}
198
199sub base {
200 my ( $self, $newbase ) = @_;
201 my $p = $self->{Parser};
202 my $oldbase = GetBase($p);
203 SetBase( $p, $newbase ) if @_ > 1;
204 return $oldbase;
205}
206
207sub context {
208 my $ctx = $_[0]->{Context};
209 @$ctx;
210}
211
212sub current_element {
213 my ($self) = @_;
214 @{ $self->{Context} } ? $self->{Context}->[-1] : undef;
215}
216
217sub in_element {
218 my ( $self, $element ) = @_;
219 @{ $self->{Context} }
220 ? $self->eq_name( $self->{Context}->[-1], $element )
221 : undef;
222}
223
224sub within_element {
225 my ( $self, $element ) = @_;
226 my $cnt = 0;
227 foreach ( @{ $self->{Context} } ) {
228 $cnt++ if $self->eq_name( $_, $element );
229 }
230 return $cnt;
231}
232
233
# spent 221ms within XML::Parser::Expat::depth which was called 431581 times, avg 513ns/call: # 363976 times (180ms+0s) by XML::Twig::_twig_end at line 2360 of XML/Twig.pm, avg 494ns/call # 33799 times (21.4ms+0s) by XML::Twig::_twig_start_check_roots at line 4134 of XML/Twig.pm, avg 633ns/call # 33792 times (20.3ms+0s) by XML::Twig::_twig_start_check_roots at line 4145 of XML/Twig.pm, avg 600ns/call # 7 times (3µs+0s) by XML::Twig::_twig_start_check_roots at line 4156 of XML/Twig.pm, avg 471ns/call # 7 times (3µs+0s) by XML::Twig::_twig_end_check_roots at line 4214 of XML/Twig.pm, avg 457ns/call
sub depth {
23443158145.7ms my ($self) = @_;
235431581868ms int( @{ $self->{Context} } );
236}
237
238sub element_index {
239 my ($self) = @_;
240
241 if ( $self->{_State_} == 1 ) {
242 return ElementIndex( $self->{Parser} );
243 }
244}
245
246################
247# Namespace methods
248
249
# spent 1.73s within XML::Parser::Expat::namespace which was called 1460048 times, avg 1µs/call: # 1095679 times (1.29s+0s) by XML::Twig::_ns_info at line 2218 of XML/Twig.pm, avg 1µs/call # 364369 times (448ms+0s) by XML::Twig::_replace_prefix at line 2426 of XML/Twig.pm, avg 1µs/call
sub namespace {
2501460048178ms my ( $self, $name ) = @_;
2511460048659ms local ($^W) = 0;
25214600483.46s $self->{Namespace_List}->[ int($name) ];
253}
254
255sub eq_name {
256 my ( $self, $nm1, $nm2 ) = @_;
257 local ($^W) = 0;
258
259 int($nm1) == int($nm2) and $nm1 eq $nm2;
260}
261
262sub generate_ns_name {
263 my ( $self, $name, $namespace ) = @_;
264
265 $namespace
266 ? GenerateNSName(
267 $name, $namespace, $self->{Namespace_Table},
268 $self->{Namespace_List}
269 )
270 : $name;
271}
272
273
# spent 243ms within XML::Parser::Expat::new_ns_prefixes which was called 398167 times, avg 611ns/call: # 398167 times (243ms+0s) by XML::Twig::_replace_ns at line 2162 of XML/Twig.pm, avg 611ns/call
sub new_ns_prefixes {
27439816739.4ms my ($self) = @_;
275398167974ms if ( $self->{Namespaces} ) {
276 return @{ $self->{New_Prefixes} };
277 }
278 return ();
279}
280
281
# spent 1.31s within XML::Parser::Expat::expand_ns_prefix which was called 1520689 times, avg 864ns/call: # 1520661 times (1.31s+0s) by XML::Twig::_a_proper_ns_prefix at line 2230 of XML/Twig.pm, avg 864ns/call # 28 times (33µs+0s) by XML::Twig::_replace_ns at line 2163 of XML/Twig.pm, avg 1µs/call
sub expand_ns_prefix {
2821520689214ms my ( $self, $prefix ) = @_;
283
2841520689158ms if ( $self->{Namespaces} ) {
2851520689365ms my $stack = $self->{Prefix_Table}->{$prefix};
28615206893.57s return ( defined($stack) and @$stack ) ? $stack->[-1] : undef;
287 }
288
289 return undef;
290}
291
292
# spent 1.51s within XML::Parser::Expat::current_ns_prefixes which was called 380001 times, avg 4µs/call: # 380001 times (1.51s+0s) by XML::Twig::_a_proper_ns_prefix at line 2229 of XML/Twig.pm, avg 4µs/call
sub current_ns_prefixes {
29338000142.5ms my ($self) = @_;
294
29538000161.6ms if ( $self->{Namespaces} ) {
296380001828ms my %set = %{ $self->{Prefix_Table} };
297
298380001112ms if ( exists $set{'#default'} and not defined( $set{'#default'}->[-1] ) ) {
299 delete $set{'#default'};
300 }
301
3023800011.24s return keys %set;
303 }
304
305 return ();
306}
307
308################################################################
309# Namespace declaration handlers
310#
311
312
# spent 66µs within XML::Parser::Expat::NamespaceStart which was called 28 times, avg 2µs/call: # 28 times (66µs+0s) by XML::Parser::Expat::ParseString at line 486, avg 2µs/call
sub NamespaceStart {
313287µs my ( $self, $prefix, $uri ) = @_;
314
315286µs $prefix = '#default' unless defined $prefix;
3162810µs my $stack = $self->{Prefix_Table}->{$prefix};
317
318286µs if ( defined $stack ) {
319 push( @$stack, $uri );
320 }
321 else {
3222717µs $self->{Prefix_Table}->{$prefix} = [$uri];
323 }
324
325 # The New_Prefixes list gets emptied at end of startElement function
326 # in Expat.xs
327
3282831µs push( @{ $self->{New_Prefixes} }, $prefix );
329}
330
331
# spent 41µs within XML::Parser::Expat::NamespaceEnd which was called 28 times, avg 1µs/call: # 28 times (41µs+0s) by XML::Parser::Expat::ParseString at line 486, avg 1µs/call
sub NamespaceEnd {
332285µs my ( $self, $prefix ) = @_;
333
334285µs $prefix = '#default' unless defined $prefix;
335
336288µs my $stack = $self->{Prefix_Table}->{$prefix};
3372826µs if ( @$stack > 1 ) {
338 pop(@$stack);
339 }
340 else {
341279µs delete $self->{Prefix_Table}->{$prefix};
342 }
343}
344
345################
346
347sub specified_attr {
348 my $self = shift;
349
350 if ( $self->{_State_} == 1 ) {
351 return GetSpecifiedAttributeCount( $self->{Parser} );
352 }
353}
354
355sub finish {
356 my ($self) = @_;
357 if ( $self->{_State_} == 1 ) {
358 my $parser = $self->{Parser};
359 UnsetAllHandlers($parser);
360 }
361}
362
363sub position_in_context {
364 my ( $self, $lines ) = @_;
365 if ( $self->{_State_} == 1 ) {
366 my $parser = $self->{Parser};
367 my ( $string, $linepos ) = PositionContext( $parser, $lines );
368
369 return '' unless defined($string);
370
371 my $col = GetCurrentColumnNumber($parser);
372 my $ptr = ( '=' x ( $col - 1 ) ) . '^' . "\n";
373 my $ret;
374 my $dosplit = $linepos < length($string);
375
376 $string .= "\n" unless $string =~ /\n$/;
377
378 if ($dosplit) {
379 $ret = substr( $string, 0, $linepos ) . $ptr . substr( $string, $linepos );
380 }
381 else {
382 $ret = $string . $ptr;
383 }
384
385 return $ret;
386 }
387}
388
389sub xml_escape {
390 my $self = shift;
391 my $text = shift;
392
393 study $text;
394 $text =~ s/\&/\&amp;/g;
395 $text =~ s/</\&lt;/g;
396 foreach (@_) {
397 croak "xml_escape: '$_' isn't a single character" if length($_) > 1;
398
399 if ( $_ eq '>' ) {
400 $text =~ s/>/\&gt;/g;
401 }
402 elsif ( $_ eq '"' ) {
403 $text =~ s/\"/\&quot;/;
404 }
405 elsif ( $_ eq "'" ) {
406 $text =~ s/\'/\&apos;/;
407 }
408 else {
409 my $rep = '&#' . sprintf( 'x%X', ord($_) ) . ';';
410 if (/\W/) {
411 my $ptrn = "\\$_";
412 $text =~ s/$ptrn/$rep/g;
413 }
414 else {
415 $text =~ s/$_/$rep/g;
416 }
417 }
418 }
419 $text;
420}
421
422sub skip_until {
423 my $self = shift;
424 if ( $self->{_State_} <= 1 ) {
425 SkipUntil( $self->{Parser}, $_[0] );
426 }
427}
428
429
# spent 18µs (15+3) within XML::Parser::Expat::release which was called 7 times, avg 3µs/call: # 7 times (15µs+3µs) by XML::Parser::parse at line 203 of XML/Parser.pm, avg 3µs/call
sub release {
43071µs my $self = shift;
431718µs73µs ParserRelease( $self->{Parser} );
# spent 3µs making 7 calls to XML::Parser::Expat::ParserRelease, avg 486ns/call
432}
433
434
# spent 632µs (15+616) within XML::Parser::Expat::DESTROY which was called 7 times, avg 90µs/call: # 7 times (15µs+616µs) by XML::Parser::parse at line 206 of XML/Parser.pm, avg 90µs/call
sub DESTROY {
43571µs my $self = shift;
4367634µs7616µs ParserFree( $self->{Parser} );
# spent 616µs making 7 calls to XML::Parser::Expat::ParserFree, avg 88µs/call
437}
438
439
# spent 70.4s (12.0ms+70.4) within XML::Parser::Expat::parse which was called 7 times, avg 10.1s/call: # 7 times (12.0ms+70.4s) by XML::Parser::parse at line 187 of XML/Parser.pm, avg 10.1s/call
sub parse {
44071µs my $self = shift;
44171µs my $arg = shift;
44272µs croak 'Parse already in progress (Expat)' if $self->{_State_};
44373µs $self->{_State_} = 1;
44472µs my $parser = $self->{Parser};
4457500ns my $ioref;
4467400ns my $result = 0;
447
44872µs if ( defined $arg ) {
44975µs local *@;
45076µs if ( ref($arg) and UNIVERSAL::isa( $arg, 'IO::Handle' ) ) {
451 $ioref = $arg;
452 }
453 elsif ( $] < 5.008 and defined tied($arg) ) {
454 require IO::Handle;
455 $ioref = $arg;
456 }
457 else {
45873µs require IO::Handle;
45972µs eval {
4602203µs220µs
# spent 14µs (7+6) within XML::Parser::Expat::BEGIN@460 which was called: # once (7µs+6µs) by XML::Parser::BEGIN@17 at line 460
no strict 'refs';
# spent 14µs making 1 call to XML::Parser::Expat::BEGIN@460 # spent 6µs making 1 call to strict::unimport
461711.9ms $ioref = *{$arg}{IO} if defined *{$arg};
462 };
46372µs if ( ref($ioref) eq 'FileHandle' ) {
464
465 #for perl 5.10.x and possibly earlier, see t/file_open_scalar.t
466 require FileHandle;
467 }
468 }
469 }
470
47173µs if ( defined($ioref) ) {
472 my $delim = $self->{Stream_Delimiter};
473 my $prev_rs;
474 my $ioclass = ref $ioref;
475 $ioclass = 'IO::Handle' if !length $ioclass;
476
477 $prev_rs = $ioclass->input_record_separator("\n$delim\n")
478 if defined($delim);
479
480 $result = ParseStream( $parser, $ioref, $delim );
481
482 $ioclass->input_record_separator($prev_rs)
483 if defined($delim);
484 }
485 else {
48671.34s856119138s $result = ParseString( $parser, $arg );
# spent 70.4s making 7 calls to XML::Parser::Expat::ParseString, avg 10.1s/call # spent 32.4s making 330576 calls to XML::Twig::_twig_start, avg 98µs/call # spent 25.4s making 364368 calls to XML::Twig::_twig_end, avg 70µs/call # spent 8.21s making 33799 calls to XML::Twig::_twig_start_check_roots, avg 243µs/call # spent 1.91s making 127292 calls to XML::Twig::_twig_char, avg 15µs/call # spent 80µs making 7 calls to XML::Twig::_twig_end_check_roots, avg 11µs/call # spent 66µs making 28 calls to XML::Parser::Expat::NamespaceStart, avg 2µs/call # spent 41µs making 28 calls to XML::Parser::Expat::NamespaceEnd, avg 1µs/call # spent 32µs making 7 calls to XML::Twig::_twig_xmldecl, avg 5µs/call # spent 23µs making 6 calls to XML::Twig::_twig_default, avg 4µs/call # spent 2µs making 1 call to XML::Twig::__ANON__[XML/Twig.pm:265]
487 }
488
48972µs $self->{_State_} = 2;
490710µs $result or croak $self->{ErrorMessage};
491}
492
493sub parsestring {
494 my $self = shift;
495 $self->parse(@_);
496}
497
498sub parsefile {
499 my $self = shift;
500 croak 'Parser has already been used' if $self->{_State_};
501
502 open( my $fh, '<', $_[0] ) or croak "Couldn't open $_[0]:\n$!";
503 binmode($fh);
504 my $ret = $self->parse($fh);
505 close($fh);
506 $ret;
507}
508
509################################################################
510package #hide from PAUSE
511 XML::Parser::ContentModel;
5122277µs240µs
# spent 25µs (10+15) within XML::Parser::ContentModel::BEGIN@512 which was called: # once (10µs+15µs) by XML::Parser::BEGIN@17 at line 512
use overload '""' => \&asString, 'eq' => \&thiseq;
# spent 25µs making 1 call to XML::Parser::ContentModel::BEGIN@512 # spent 15µs making 1 call to overload::import
513
514sub EMPTY () { 1 }
515sub ANY () { 2 }
516sub MIXED () { 3 }
517sub NAME () { 4 }
518sub CHOICE () { 5 }
519sub SEQ () { 6 }
520
521sub isempty {
522 return $_[0]->{Type} == EMPTY;
523}
524
525sub isany {
526 return $_[0]->{Type} == ANY;
527}
528
529sub ismixed {
530 return $_[0]->{Type} == MIXED;
531}
532
533sub isname {
534 return $_[0]->{Type} == NAME;
535}
536
537sub name {
538 return $_[0]->{Tag};
539}
540
541sub ischoice {
542 return $_[0]->{Type} == CHOICE;
543}
544
545sub isseq {
546 return $_[0]->{Type} == SEQ;
547}
548
549sub quant {
550 return $_[0]->{Quant};
551}
552
553sub children {
554 my $children = $_[0]->{Children};
555 if ( defined $children ) {
556 return @$children;
557 }
558 return undef;
559}
560
561sub asString {
562 my ($self) = @_;
563 my $ret;
564
565 if ( $self->{Type} == NAME ) {
566 $ret = $self->{Tag};
567 }
568 elsif ( $self->{Type} == EMPTY ) {
569 return 'EMPTY';
570 }
571 elsif ( $self->{Type} == ANY ) {
572 return 'ANY';
573 }
574 elsif ( $self->{Type} == MIXED ) {
575 $ret = '(#PCDATA';
576 foreach ( @{ $self->{Children} } ) {
577 $ret .= '|' . $_;
578 }
579 $ret .= ')';
580 }
581 else {
582 my $sep = $self->{Type} == CHOICE ? '|' : ',';
583 $ret = '(' . join( $sep, map { $_->asString } @{ $self->{Children} } ) . ')';
584 }
585
586 $ret .= $self->{Quant} if $self->{Quant};
587 return $ret;
588}
589
590sub thiseq {
591 my $self = shift;
592
593 return $self->asString eq $_[0];
594}
595
596################################################################
597package #hide from PAUSE
598 XML::Parser::ExpatNB;
599
6002223µs249µs
# spent 27µs (5+22) within XML::Parser::ExpatNB::BEGIN@600 which was called: # once (5µs+22µs) by XML::Parser::BEGIN@17 at line 600
use Carp;
# spent 27µs making 1 call to XML::Parser::ExpatNB::BEGIN@600 # spent 22µs making 1 call to Exporter::import
601
60215µsour @ISA = qw(XML::Parser::Expat);
603
604sub parse {
605 my $self = shift;
606 my $class = ref($self);
607 croak "parse method not supported in $class";
608}
609
610sub parsestring {
611 my $self = shift;
612 my $class = ref($self);
613 croak "parsestring method not supported in $class";
614}
615
616sub parsefile {
617 my $self = shift;
618 my $class = ref($self);
619 croak "parsefile method not supported in $class";
620}
621
622sub parse_more {
623 my ( $self, $data ) = @_;
624
625 $self->{_State_} = 1;
626 my $ret = XML::Parser::Expat::ParsePartial( $self->{Parser}, $data );
627
628 croak $self->{ErrorMessage} unless $ret;
629}
630
631sub parse_done {
632 my $self = shift;
633
634 my $ret = XML::Parser::Expat::ParseDone( $self->{Parser} );
635 unless ($ret) {
636 my $msg = $self->{ErrorMessage};
637 $self->release;
638 croak $msg;
639 }
640
641 $self->{_State_} = 2;
642
643 my $result = $ret;
644 my @result = ();
645 my $final = $self->{FinalHandler};
646 if ( defined $final ) {
647 if (wantarray) {
648 @result = &$final($self);
649 }
650 else {
651 $result = &$final($self);
652 }
653 }
654
655 $self->release;
656
657 return unless defined wantarray;
658 return wantarray ? @result : $result;
659}
660
661################################################################
662
663package #hide from PAUSE
664 XML::Parser::Encinfo;
665
666sub DESTROY {
667 my $self = shift;
668 XML::Parser::Expat::FreeEncoding($self);
669}
670
67119µs1;
672
673__END__
 
# spent 70.4s (2.57+67.9) within XML::Parser::Expat::ParseString which was called 7 times, avg 10.1s/call: # 7 times (2.57s+67.9s) by XML::Parser::Expat::parse at line 486, avg 10.1s/call
sub XML::Parser::Expat::ParseString; # xsub
# spent 47µs within XML::Parser::Expat::ParserCreate which was called 7 times, avg 7µs/call: # 7 times (47µs+0s) by XML::Parser::Expat::new at line 69, avg 7µs/call
sub XML::Parser::Expat::ParserCreate; # xsub
# spent 616µs within XML::Parser::Expat::ParserFree which was called 7 times, avg 88µs/call: # 7 times (616µs+0s) by XML::Parser::Expat::DESTROY at line 436, avg 88µs/call
sub XML::Parser::Expat::ParserFree; # xsub
# spent 3µs within XML::Parser::Expat::ParserRelease which was called 7 times, avg 486ns/call: # 7 times (3µs+0s) by XML::Parser::Expat::release at line 431, avg 486ns/call
sub XML::Parser::Expat::ParserRelease; # xsub
# spent 223ms within XML::Parser::Expat::RecognizedString which was called 364369 times, avg 613ns/call: # 364369 times (223ms+0s) by XML::Parser::Expat::recognized_string at line 166, avg 613ns/call
sub XML::Parser::Expat::RecognizedString; # xsub
# spent 20.8ms within XML::Parser::Expat::SetAttListDeclHandler which was called 67591 times, avg 308ns/call: # 67591 times (20.8ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 308ns/call
sub XML::Parser::Expat::SetAttListDeclHandler; # xsub
# spent 20.4ms within XML::Parser::Expat::SetCharacterDataHandler which was called 67591 times, avg 301ns/call: # 67591 times (20.4ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 301ns/call
sub XML::Parser::Expat::SetCharacterDataHandler; # xsub
# spent 20.5ms within XML::Parser::Expat::SetCommentHandler which was called 67591 times, avg 303ns/call: # 67591 times (20.5ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 303ns/call
sub XML::Parser::Expat::SetCommentHandler; # xsub
# spent 17.4ms within XML::Parser::Expat::SetDefaultHandler which was called 67598 times, avg 258ns/call: # 67598 times (17.4ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 258ns/call
sub XML::Parser::Expat::SetDefaultHandler; # xsub
# spent 17.8ms within XML::Parser::Expat::SetDoctypeHandler which was called 67591 times, avg 264ns/call: # 67591 times (17.8ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 264ns/call
sub XML::Parser::Expat::SetDoctypeHandler; # xsub
# spent 19.4ms within XML::Parser::Expat::SetElementDeclHandler which was called 67591 times, avg 287ns/call: # 67591 times (19.4ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 287ns/call
sub XML::Parser::Expat::SetElementDeclHandler; # xsub
# spent 20.2ms within XML::Parser::Expat::SetEndCdataHandler which was called 67591 times, avg 299ns/call: # 67591 times (20.2ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 299ns/call
sub XML::Parser::Expat::SetEndCdataHandler; # xsub
# spent 22.2ms within XML::Parser::Expat::SetEndElementHandler which was called 67591 times, avg 329ns/call: # 67591 times (22.2ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 329ns/call
sub XML::Parser::Expat::SetEndElementHandler; # xsub
# spent 21.1ms within XML::Parser::Expat::SetEntityDeclHandler which was called 67591 times, avg 312ns/call: # 67591 times (21.1ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 312ns/call
sub XML::Parser::Expat::SetEntityDeclHandler; # xsub
# spent 20.1ms within XML::Parser::Expat::SetExternalEntityRefHandler which was called 67591 times, avg 298ns/call: # 67591 times (20.1ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 298ns/call
sub XML::Parser::Expat::SetExternalEntityRefHandler; # xsub
# spent 10.5ms within XML::Parser::Expat::SetNotationDeclHandler which was called 33798 times, avg 310ns/call: # 33798 times (10.5ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 310ns/call
sub XML::Parser::Expat::SetNotationDeclHandler; # xsub
# spent 17.8ms within XML::Parser::Expat::SetProcessingInstructionHandler which was called 67591 times, avg 263ns/call: # 67591 times (17.8ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 263ns/call
sub XML::Parser::Expat::SetProcessingInstructionHandler; # xsub
# spent 18.9ms within XML::Parser::Expat::SetStartCdataHandler which was called 67591 times, avg 279ns/call: # 67591 times (18.9ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 279ns/call
sub XML::Parser::Expat::SetStartCdataHandler; # xsub
# spent 15.7ms within XML::Parser::Expat::SetStartElementHandler which was called 67591 times, avg 232ns/call: # 67591 times (15.7ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 232ns/call
sub XML::Parser::Expat::SetStartElementHandler; # xsub
# spent 26.8ms within XML::Parser::Expat::SetXMLDeclHandler which was called 67591 times, avg 396ns/call: # 67591 times (26.8ms+0s) by XML::Parser::Expat::setHandlers at line 128, avg 396ns/call
sub XML::Parser::Expat::SetXMLDeclHandler; # xsub