← Index
NYTProf Performance Profile   « block view • line view • sub view »
For conv.pl
  Run on Sun Nov 14 21:14:18 2010
Reported on Sun Nov 14 21:17:53 2010

Filename/usr/lib/perl5/XML/Parser/Expat.pm
StatementsExecuted 740036 statements in 8.34s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
5000116.75s83.2sXML::Parser::Expat::::ParseString XML::Parser::Expat::ParseString (xsub)
5000111.22s1.47sXML::Parser::Expat::::setHandlers XML::Parser::Expat::setHandlers
500011227ms83.4sXML::Parser::Expat::::parse XML::Parser::Expat::parse
500011143ms198msXML::Parser::Expat::::new XML::Parser::Expat::new
50001178.2ms78.2msXML::Parser::Expat::::ParserFree XML::Parser::Expat::ParserFree (xsub)
50001155.0ms55.0msXML::Parser::Expat::::ParserCreate XML::Parser::Expat::ParserCreate (xsub)
50001149.2ms127msXML::Parser::Expat::::DESTROY XML::Parser::Expat::DESTROY
50001146.7ms61.0msXML::Parser::Expat::::release XML::Parser::Expat::release
50001117.2ms17.2msXML::Parser::Expat::::SetEndCdataHandler XML::Parser::Expat::SetEndCdataHandler (xsub)
50001116.7ms16.7msXML::Parser::Expat::::SetUnparsedEntityDeclHandler XML::Parser::Expat::SetUnparsedEntityDeclHandler (xsub)
50001115.5ms15.5msXML::Parser::Expat::::SetProcessingInstructionHandler XML::Parser::Expat::SetProcessingInstructionHandler (xsub)
50001115.5ms15.5msXML::Parser::Expat::::SetExternalEntityRefHandler XML::Parser::Expat::SetExternalEntityRefHandler (xsub)
50001115.2ms15.2msXML::Parser::Expat::::SetDoctypeHandler XML::Parser::Expat::SetDoctypeHandler (xsub)
50001115.1ms15.1msXML::Parser::Expat::::SetCharacterDataHandler XML::Parser::Expat::SetCharacterDataHandler (xsub)
50001114.9ms14.9msXML::Parser::Expat::::SetElementDeclHandler XML::Parser::Expat::SetElementDeclHandler (xsub)
50001114.9ms14.9msXML::Parser::Expat::::SetStartElementHandler XML::Parser::Expat::SetStartElementHandler (xsub)
50001114.9ms14.9msXML::Parser::Expat::::SetXMLDeclHandler XML::Parser::Expat::SetXMLDeclHandler (xsub)
50001114.9ms14.9msXML::Parser::Expat::::SetEndDoctypeHandler XML::Parser::Expat::SetEndDoctypeHandler (xsub)
50001114.8ms14.8msXML::Parser::Expat::::SetNotationDeclHandler XML::Parser::Expat::SetNotationDeclHandler (xsub)
50001114.7ms14.7msXML::Parser::Expat::::SetCommentHandler XML::Parser::Expat::SetCommentHandler (xsub)
50001114.7ms14.7msXML::Parser::Expat::::SetStartCdataHandler XML::Parser::Expat::SetStartCdataHandler (xsub)
50001114.2ms14.2msXML::Parser::Expat::::ParserRelease XML::Parser::Expat::ParserRelease (xsub)
50001114.2ms14.2msXML::Parser::Expat::::SetAttListDeclHandler XML::Parser::Expat::SetAttListDeclHandler (xsub)
50001114.0ms14.0msXML::Parser::Expat::::SetEndElementHandler XML::Parser::Expat::SetEndElementHandler (xsub)
50001114.0ms14.0msXML::Parser::Expat::::SetEntityDeclHandler XML::Parser::Expat::SetEntityDeclHandler (xsub)
11194µs94µsXML::Parser::Expat::::bootstrap XML::Parser::Expat::bootstrap (xsub)
111157µs57µsXML::Parser::Expat::::CORE:ftdir XML::Parser::Expat::CORE:ftdir (opcode)
11140µs112µsXML::Parser::ContentModel::::BEGIN@499XML::Parser::ContentModel::BEGIN@499
11122µs27µsXML::Parser::Expat::::BEGIN@5 XML::Parser::Expat::BEGIN@5
11118µs47µsXML::Parser::Expat::::BEGIN@449 XML::Parser::Expat::BEGIN@449
11117µs40µsXML::Parser::Expat::::BEGIN@455 XML::Parser::Expat::BEGIN@455
11117µs104µsXML::Parser::ExpatNB::::BEGIN@588 XML::Parser::ExpatNB::BEGIN@588
11116µs63µsXML::Parser::ExpatNB::::BEGIN@587 XML::Parser::ExpatNB::BEGIN@587
11114µs86µsXML::Parser::Expat::::BEGIN@8 XML::Parser::Expat::BEGIN@8
11114µs205µsXML::Parser::Expat::::BEGIN@6 XML::Parser::Expat::BEGIN@6
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::::NamespaceEnd XML::Parser::Expat::NamespaceEnd
0000s0sXML::Parser::Expat::::NamespaceStart XML::Parser::Expat::NamespaceStart
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::::current_ns_prefixes XML::Parser::Expat::current_ns_prefixes
0000s0sXML::Parser::Expat::::default_current XML::Parser::Expat::default_current
0000s0sXML::Parser::Expat::::depth XML::Parser::Expat::depth
0000s0sXML::Parser::Expat::::element_index XML::Parser::Expat::element_index
0000s0sXML::Parser::Expat::::eq_name XML::Parser::Expat::eq_name
0000s0sXML::Parser::Expat::::expand_ns_prefix XML::Parser::Expat::expand_ns_prefix
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::::namespace XML::Parser::Expat::namespace
0000s0sXML::Parser::Expat::::new_ns_prefixes XML::Parser::Expat::new_ns_prefixes
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::::recognized_string XML::Parser::Expat::recognized_string
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
3164µsrequire 5.004;
4
5347µs232µs
# spent 27µs (22+5) within XML::Parser::Expat::BEGIN@5 which was called: # once (22µs+5µs) by XML::Parser::BEGIN@13 at line 5
use strict;
# spent 27µs making 1 call to XML::Parser::Expat::BEGIN@5 # spent 5µs making 1 call to strict::import
61191µs
# spent 205µs (14+191) within XML::Parser::Expat::BEGIN@6 which was called: # once (14µs+191µs) by XML::Parser::BEGIN@13 at line 7
use vars qw($VERSION @ISA %Handler_Setters %Encoding_Table @Encoding_Path
# spent 191µs making 1 call to vars::import
7341µs1205µs $have_File_Spec);
# spent 205µs making 1 call to XML::Parser::Expat::BEGIN@6
833.10ms2158µs
# spent 86µs (14+72) within XML::Parser::Expat::BEGIN@8 which was called: # once (14µs+72µs) by XML::Parser::BEGIN@13 at line 8
use Carp;
# spent 86µs making 1 call to XML::Parser::Expat::BEGIN@8 # spent 72µs making 1 call to Exporter::import
9
1011µsrequire DynaLoader;
11
12119µs@ISA = qw(DynaLoader);
1312µs$VERSION = "2.36" ;
14
1512µs$have_File_Spec = $INC{'File/Spec.pm'} || do 'File/Spec.pm';
16
1711µs%Encoding_Table = ();
182157µsif ($have_File_Spec) {
1923619µs @Encoding_Path = (grep(-d $_,
# spent 560µs making 11 calls to File::Spec::Unix::catdir, avg 51µs/call # spent 57µs making 11 calls to XML::Parser::Expat::CORE:ftdir, avg 5µs/call # spent 2µs making 1 call to File::Spec::Unix::curdir
20 map(File::Spec->catdir($_, qw(XML Parser Encodings)),
21 @INC)),
22 File::Spec->curdir);
23}
24else {
25 @Encoding_Path = (grep(-d $_, map($_ . '/XML/Parser/Encodings', @INC)), '.');
26}
27
28
2919µs1568µsbootstrap XML::Parser::Expat $VERSION;
# spent 568µs making 1 call to DynaLoader::bootstrap
30
31121µs%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 198ms (143+55.0) within XML::Parser::Expat::new which was called 5000 times, avg 40µs/call: # 5000 times (143ms+55.0ms) by XML::Parser::parse at line 170 of XML/Parser.pm, avg 40µs/call
sub new {
5350000201ms my ($class, %args) = @_;
54 my $self = bless \%args, $_[0];
55 $args{_State_} = 0;
56 $args{Context} = [];
57 $args{Namespaces} ||= 0;
58 $args{ErrorMessage} ||= '';
59 if ($args{Namespaces}) {
60 $args{Namespace_Table} = {};
61 $args{Namespace_List} = [undef];
62 $args{Prefix_Table} = {};
63 $args{New_Prefixes} = [];
64 }
65 $args{_Setters} = \%Handler_Setters;
66500055.0ms $args{Parser} = ParserCreate($self, $args{ProtocolEncoding},
# spent 55.0ms making 5000 calls to XML::Parser::Expat::ParserCreate, avg 11µs/call
67 $args{Namespaces});
68 $self;
69}
70
71sub load_encoding {
72 my ($file) = @_;
73
74 $file =~ s!([^/]+)$!\L$1\E!;
75 $file .= '.enc' unless $file =~ /\.enc$/;
76 unless ($file =~ m!^/!) {
77 foreach (@Encoding_Path) {
78 my $tmp = ($have_File_Spec
79 ? File::Spec->catfile($_, $file)
80 : "$_/$file");
81 if (-e $tmp) {
82 $file = $tmp;
83 last;
84 }
85 }
86 }
87
88 local(*ENC);
89 open(ENC, $file) or croak("Couldn't open encmap $file:\n$!\n");
90 binmode(ENC);
91 my $data;
92 my $br = sysread(ENC, $data, -s $file);
93 croak("Trouble reading $file:\n$!\n")
94 unless defined($br);
95 close(ENC);
96
97 my $name = LoadEncoding($data, $br);
98 croak("$file isn't an encmap file")
99 unless defined($name);
100
101 $name;
102} # End load_encoding
103
104
# spent 1.47s (1.22+241ms) within XML::Parser::Expat::setHandlers which was called 5000 times, avg 293µs/call: # 5000 times (1.22s+241ms) by XML::Parser::parse at line 175 of XML/Parser.pm, avg 293µs/call
sub setHandlers {
1052500096.6ms my ($self, @handler_pairs) = @_;
106
107 croak("Uneven number of arguments to setHandlers method")
108 if (int(@handler_pairs) & 1);
109
110 my @ret;
111
112 while (@handler_pairs) {
1135600001.37s my $type = shift @handler_pairs;
114 my $handler = shift @handler_pairs;
115 croak "Handler for $type not a Code ref"
116 unless (! defined($handler) or ! $handler or ref($handler) eq 'CODE');
117
118 my $hndl = $self->{_Setters}->{$type};
119
120 unless (defined($hndl)) {
121 my @types = sort keys %{$self->{_Setters}};
122 croak("Unknown Expat handler type: $type\n Valid types: @types");
123 }
124
12580000241ms my $old = &$hndl($self->{Parser}, $handler);
# spent 17.2ms making 5000 calls to XML::Parser::Expat::SetEndCdataHandler, avg 3µs/call # spent 16.7ms making 5000 calls to XML::Parser::Expat::SetUnparsedEntityDeclHandler, avg 3µs/call # spent 15.5ms making 5000 calls to XML::Parser::Expat::SetProcessingInstructionHandler, avg 3µs/call # spent 15.5ms making 5000 calls to XML::Parser::Expat::SetExternalEntityRefHandler, avg 3µs/call # spent 15.2ms making 5000 calls to XML::Parser::Expat::SetDoctypeHandler, avg 3µs/call # spent 15.1ms making 5000 calls to XML::Parser::Expat::SetCharacterDataHandler, avg 3µs/call # spent 14.9ms making 5000 calls to XML::Parser::Expat::SetElementDeclHandler, avg 3µs/call # spent 14.9ms making 5000 calls to XML::Parser::Expat::SetStartElementHandler, avg 3µs/call # spent 14.9ms making 5000 calls to XML::Parser::Expat::SetXMLDeclHandler, avg 3µs/call # spent 14.9ms making 5000 calls to XML::Parser::Expat::SetEndDoctypeHandler, avg 3µs/call # spent 14.8ms making 5000 calls to XML::Parser::Expat::SetNotationDeclHandler, avg 3µs/call # spent 14.7ms making 5000 calls to XML::Parser::Expat::SetCommentHandler, avg 3µs/call # spent 14.7ms making 5000 calls to XML::Parser::Expat::SetStartCdataHandler, avg 3µs/call # spent 14.2ms making 5000 calls to XML::Parser::Expat::SetAttListDeclHandler, avg 3µs/call # spent 14.0ms making 5000 calls to XML::Parser::Expat::SetEndElementHandler, avg 3µs/call # spent 14.0ms making 5000 calls to XML::Parser::Expat::SetEntityDeclHandler, avg 3µs/call
126 push (@ret, $type, $old);
127 }
128
129 return @ret;
130}
131
132sub xpcroak
133 {
134 my ($self, $message) = @_;
135
136 my $eclines = $self->{ErrorContext};
137 my $line = GetCurrentLineNumber($_[0]->{Parser});
138 $message .= " at line $line";
139 $message .= ":\n" . $self->position_in_context($eclines)
140 if defined($eclines);
141 croak $message;
142}
143
144sub xpcarp {
145 my ($self, $message) = @_;
146
147 my $eclines = $self->{ErrorContext};
148 my $line = GetCurrentLineNumber($_[0]->{Parser});
149 $message .= " at line $line";
150 $message .= ":\n" . $self->position_in_context($eclines)
151 if defined($eclines);
152 carp $message;
153}
154
155sub default_current {
156 my $self = shift;
157 if ($self->{_State_} == 1) {
158 return DefaultCurrent($self->{Parser});
159 }
160}
161
162sub recognized_string {
163 my $self = shift;
164 if ($self->{_State_} == 1) {
165 return RecognizedString($self->{Parser});
166 }
167}
168
169sub original_string {
170 my $self = shift;
171 if ($self->{_State_} == 1) {
172 return OriginalString($self->{Parser});
173 }
174}
175
176sub current_line {
177 my $self = shift;
178 if ($self->{_State_} == 1) {
179 return GetCurrentLineNumber($self->{Parser});
180 }
181}
182
183sub current_column {
184 my $self = shift;
185 if ($self->{_State_} == 1) {
186 return GetCurrentColumnNumber($self->{Parser});
187 }
188}
189
190sub current_byte {
191 my $self = shift;
192 if ($self->{_State_} == 1) {
193 return GetCurrentByteIndex($self->{Parser});
194 }
195}
196
197sub base {
198 my ($self, $newbase) = @_;
199 my $p = $self->{Parser};
200 my $oldbase = GetBase($p);
201 SetBase($p, $newbase) if @_ > 1;
202 return $oldbase;
203}
204
205sub context {
206 my $ctx = $_[0]->{Context};
207 @$ctx;
208}
209
210sub current_element {
211 my ($self) = @_;
212 @{$self->{Context}} ? $self->{Context}->[-1] : undef;
213}
214
215sub in_element {
216 my ($self, $element) = @_;
217 @{$self->{Context}} ? $self->eq_name($self->{Context}->[-1], $element)
218 : undef;
219}
220
221sub within_element {
222 my ($self, $element) = @_;
223 my $cnt = 0;
224 foreach (@{$self->{Context}}) {
225 $cnt++ if $self->eq_name($_, $element);
226 }
227 return $cnt;
228}
229
230sub depth {
231 my ($self) = @_;
232 int(@{$self->{Context}});
233}
234
235sub element_index {
236 my ($self) = @_;
237
238 if ($self->{_State_} == 1) {
239 return ElementIndex($self->{Parser});
240 }
241}
242
243################
244# Namespace methods
245
246sub namespace {
247 my ($self, $name) = @_;
248 local($^W) = 0;
249 $self->{Namespace_List}->[int($name)];
250}
251
252sub eq_name {
253 my ($self, $nm1, $nm2) = @_;
254 local($^W) = 0;
255
256 int($nm1) == int($nm2) and $nm1 eq $nm2;
257}
258
259sub generate_ns_name {
260 my ($self, $name, $namespace) = @_;
261
262 $namespace ?
263 GenerateNSName($name, $namespace, $self->{Namespace_Table},
264 $self->{Namespace_List})
265 : $name;
266}
267
268sub new_ns_prefixes {
269 my ($self) = @_;
270 if ($self->{Namespaces}) {
271 return @{$self->{New_Prefixes}};
272 }
273 return ();
274}
275
276sub expand_ns_prefix {
277 my ($self, $prefix) = @_;
278
279 if ($self->{Namespaces}) {
280 my $stack = $self->{Prefix_Table}->{$prefix};
281 return (defined($stack) and @$stack) ? $stack->[-1] : undef;
282 }
283
284 return undef;
285}
286
287sub current_ns_prefixes {
288 my ($self) = @_;
289
290 if ($self->{Namespaces}) {
291 my %set = %{$self->{Prefix_Table}};
292
293 if (exists $set{'#default'} and not defined($set{'#default'}->[-1])) {
294 delete $set{'#default'};
295 }
296
297 return keys %set;
298 }
299
300 return ();
301}
302
303
304################################################################
305# Namespace declaration handlers
306#
307
308sub NamespaceStart {
309 my ($self, $prefix, $uri) = @_;
310
311 $prefix = '#default' unless defined $prefix;
312 my $stack = $self->{Prefix_Table}->{$prefix};
313
314 if (defined $stack) {
315 push(@$stack, $uri);
316 }
317 else {
318 $self->{Prefix_Table}->{$prefix} = [$uri];
319 }
320
321 # The New_Prefixes list gets emptied at end of startElement function
322 # in Expat.xs
323
324 push(@{$self->{New_Prefixes}}, $prefix);
325}
326
327sub NamespaceEnd {
328 my ($self, $prefix) = @_;
329
330 $prefix = '#default' unless defined $prefix;
331
332 my $stack = $self->{Prefix_Table}->{$prefix};
333 if (@$stack > 1) {
334 pop(@$stack);
335 }
336 else {
337 delete $self->{Prefix_Table}->{$prefix};
338 }
339}
340
341################
342
343sub specified_attr {
344 my $self = shift;
345
346 if ($self->{_State_} == 1) {
347 return GetSpecifiedAttributeCount($self->{Parser});
348 }
349}
350
351sub finish {
352 my ($self) = @_;
353 if ($self->{_State_} == 1) {
354 my $parser = $self->{Parser};
355 UnsetAllHandlers($parser);
356 }
357}
358
359sub position_in_context {
360 my ($self, $lines) = @_;
361 if ($self->{_State_} == 1) {
362 my $parser = $self->{Parser};
363 my ($string, $linepos) = PositionContext($parser, $lines);
364
365 return '' unless defined($string);
366
367 my $col = GetCurrentColumnNumber($parser);
368 my $ptr = ('=' x ($col - 1)) . '^' . "\n";
369 my $ret;
370 my $dosplit = $linepos < length($string);
371
372 $string .= "\n" unless $string =~ /\n$/;
373
374 if ($dosplit) {
375 $ret = substr($string, 0, $linepos) . $ptr
376 . substr($string, $linepos);
377 } else {
378 $ret = $string . $ptr;
379 }
380
381 return $ret;
382 }
383}
384
385sub xml_escape {
386 my $self = shift;
387 my $text = shift;
388
389 study $text;
390 $text =~ s/\&/\&amp;/g;
391 $text =~ s/</\&lt;/g;
392 foreach (@_) {
393 croak "xml_escape: '$_' isn't a single character" if length($_) > 1;
394
395 if ($_ eq '>') {
396 $text =~ s/>/\&gt;/g;
397 }
398 elsif ($_ eq '"') {
399 $text =~ s/\"/\&quot;/;
400 }
401 elsif ($_ eq "'") {
402 $text =~ s/\'/\&apos;/;
403 }
404 else {
405 my $rep = '&#' . sprintf('x%X', ord($_)) . ';';
406 if (/\W/) {
407 my $ptrn = "\\$_";
408 $text =~ s/$ptrn/$rep/g;
409 }
410 else {
411 $text =~ s/$_/$rep/g;
412 }
413 }
414 }
415 $text;
416}
417
418sub skip_until {
419 my $self = shift;
420 if ($self->{_State_} <= 1) {
421 SkipUntil($self->{Parser}, $_[0]);
422 }
423}
424
425
# spent 61.0ms (46.7+14.3) within XML::Parser::Expat::release which was called 5000 times, avg 12µs/call: # 5000 times (46.7ms+14.3ms) by XML::Parser::parse at line 204 of XML/Parser.pm, avg 12µs/call
sub release {
4261000061.2ms my $self = shift;
427500014.2ms ParserRelease($self->{Parser});
# spent 14.2ms making 5000 calls to XML::Parser::Expat::ParserRelease, avg 3µs/call
428}
429
430
# spent 127ms (49.2+78.2) within XML::Parser::Expat::DESTROY which was called 5000 times, avg 25µs/call: # 5000 times (49.2ms+78.2ms) by XML::Parser::parse at line 60 of XML/SAX/Expat.pm, avg 25µs/call
sub DESTROY {
43110000127ms my $self = shift;
432500078.2ms ParserFree($self->{Parser});
# spent 78.2ms making 5000 calls to XML::Parser::Expat::ParserFree, avg 16µs/call
433}
434
435
# spent 83.4s (227ms+83.2) within XML::Parser::Expat::parse which was called 5000 times, avg 16.7ms/call: # 5000 times (227ms+83.2s) by XML::Parser::parse at line 187 of XML/Parser.pm, avg 16.7ms/call
sub parse {
43655000102ms my $self = shift;
437 my $arg = shift;
438 croak "Parse already in progress (Expat)" if $self->{_State_};
439 $self->{_State_} = 1;
440 my $parser = $self->{Parser};
441 my $ioref;
442 my $result = 0;
443
444500013.6ms if (defined $arg) {
4451500028.2ms if (ref($arg) and UNIVERSAL::isa($arg, 'IO::Handle')) {
446 $ioref = $arg;
447 } elsif (tied($arg)) {
448 my $class = ref($arg);
449377µs276µs
# spent 47µs (18+29) within XML::Parser::Expat::BEGIN@449 which was called: # once (18µs+29µs) by XML::Parser::BEGIN@13 at line 449
no strict 'refs';
# spent 47µs making 1 call to XML::Parser::Expat::BEGIN@449 # spent 29µs making 1 call to strict::unimport
450 $ioref = $arg if defined &{"${class}::TIEHANDLE"};
451 }
452 else {
453 require IO::Handle;
454500062.5ms eval {
4553386µs263µs
# spent 40µs (17+23) within XML::Parser::Expat::BEGIN@455 which was called: # once (17µs+23µs) by XML::Parser::BEGIN@13 at line 455
no strict 'refs';
# spent 40µs making 1 call to XML::Parser::Expat::BEGIN@455 # spent 23µs making 1 call to strict::unimport
456 $ioref = *{$arg}{IO} if defined *{$arg};
457 };
458 undef $@;
459 }
460 }
461
462500079.4ms if (defined($ioref)) {
463 my $delim = $self->{Stream_Delimiter};
464 my $prev_rs;
465
466 $prev_rs = ref($ioref)->input_record_separator("\n$delim\n")
467 if defined($delim);
468
469 $result = ParseStream($parser, $ioref, $delim);
470
471 ref($ioref)->input_record_separator($prev_rs)
472 if defined($delim);
473 } else {
47416.19s983004160s $result = ParseString($parser, $arg);
# spent 83.2s making 5000 calls to XML::Parser::Expat::ParseString, avg 16.6ms/call # spent 34.3s making 185299 calls to XML::SAX::Expat::_handle_start, avg 185µs/call # spent 22.3s making 607406 calls to XML::SAX::Expat::_handle_char, avg 37µs/call # spent 19.8s making 185299 calls to XML::SAX::Expat::_handle_end, avg 107µs/call
475 }
476
477 $self->{_State_} = 2;
478 $result or croak $self->{ErrorMessage};
479}
480
481sub parsestring {
482 my $self = shift;
483 $self->parse(@_);
484}
485
486sub parsefile {
487 my $self = shift;
488 croak "Parser has already been used" if $self->{_State_};
489 local(*FILE);
490 open(FILE, $_[0]) or croak "Couldn't open $_[0]:\n$!";
491 binmode(FILE);
492 my $ret = $self->parse(*FILE);
493 close(FILE);
494 $ret;
495}
496
497################################################################
498package XML::Parser::ContentModel;
4993636µs2184µs
# spent 112µs (40+72) within XML::Parser::ContentModel::BEGIN@499 which was called: # once (40µs+72µs) by XML::Parser::BEGIN@13 at line 499
use overload '""' => \&asString, 'eq' => \&thiseq;
# spent 112µs making 1 call to XML::Parser::ContentModel::BEGIN@499 # spent 72µs making 1 call to overload::import
500
501sub EMPTY () {1}
502sub ANY () {2}
503sub MIXED () {3}
504sub NAME () {4}
505sub CHOICE () {5}
506sub SEQ () {6}
507
508
509sub isempty {
510 return $_[0]->{Type} == EMPTY;
511}
512
513sub isany {
514 return $_[0]->{Type} == ANY;
515}
516
517sub ismixed {
518 return $_[0]->{Type} == MIXED;
519}
520
521sub isname {
522 return $_[0]->{Type} == NAME;
523}
524
525sub name {
526 return $_[0]->{Tag};
527}
528
529sub ischoice {
530 return $_[0]->{Type} == CHOICE;
531}
532
533sub isseq {
534 return $_[0]->{Type} == SEQ;
535}
536
537sub quant {
538 return $_[0]->{Quant};
539}
540
541sub children {
542 my $children = $_[0]->{Children};
543 if (defined $children) {
544 return @$children;
545 }
546 return undef;
547}
548
549sub asString {
550 my ($self) = @_;
551 my $ret;
552
553 if ($self->{Type} == NAME) {
554 $ret = $self->{Tag};
555 }
556 elsif ($self->{Type} == EMPTY) {
557 return "EMPTY";
558 }
559 elsif ($self->{Type} == ANY) {
560 return "ANY";
561 }
562 elsif ($self->{Type} == MIXED) {
563 $ret = '(#PCDATA';
564 foreach (@{$self->{Children}}) {
565 $ret .= '|' . $_;
566 }
567 $ret .= ')';
568 }
569 else {
570 my $sep = $self->{Type} == CHOICE ? '|' : ',';
571 $ret = '(' . join($sep, map { $_->asString } @{$self->{Children}}) . ')';
572 }
573
574 $ret .= $self->{Quant} if $self->{Quant};
575 return $ret;
576}
577
578sub thiseq {
579 my $self = shift;
580
581 return $self->asString eq $_[0];
582}
583
584################################################################
585package XML::Parser::ExpatNB;
586
587342µs2110µs
# spent 63µs (16+47) within XML::Parser::ExpatNB::BEGIN@587 which was called: # once (16µs+47µs) by XML::Parser::BEGIN@13 at line 587
use vars qw(@ISA);
# spent 63µs making 1 call to XML::Parser::ExpatNB::BEGIN@587 # spent 47µs making 1 call to vars::import
5883487µs2191µs
# spent 104µs (17+87) within XML::Parser::ExpatNB::BEGIN@588 which was called: # once (17µs+87µs) by XML::Parser::BEGIN@13 at line 588
use Carp;
# spent 104µs making 1 call to XML::Parser::ExpatNB::BEGIN@588 # spent 87µs making 1 call to Exporter::import
589
590111µs@ISA = qw(XML::Parser::Expat);
591
592sub parse {
593 my $self = shift;
594 my $class = ref($self);
595 croak "parse method not supported in $class";
596}
597
598sub parsestring {
599 my $self = shift;
600 my $class = ref($self);
601 croak "parsestring method not supported in $class";
602}
603
604sub parsefile {
605 my $self = shift;
606 my $class = ref($self);
607 croak "parsefile method not supported in $class";
608}
609
610sub parse_more {
611 my ($self, $data) = @_;
612
613 $self->{_State_} = 1;
614 my $ret = XML::Parser::Expat::ParsePartial($self->{Parser}, $data);
615
616 croak $self->{ErrorMessage} unless $ret;
617}
618
619sub parse_done {
620 my $self = shift;
621
622 my $ret = XML::Parser::Expat::ParseDone($self->{Parser});
623 unless ($ret) {
624 my $msg = $self->{ErrorMessage};
625 $self->release;
626 croak $msg;
627 }
628
629 $self->{_State_} = 2;
630
631 my $result = $ret;
632 my @result = ();
633 my $final = $self->{FinalHandler};
634 if (defined $final) {
635 if (wantarray) {
636 @result = &$final($self);
637 }
638 else {
639 $result = &$final($self);
640 }
641 }
642
643 $self->release;
644
645 return unless defined wantarray;
646 return wantarray ? @result : $result;
647}
648
649################################################################
650
651package XML::Parser::Encinfo;
652
653sub DESTROY {
654 my $self = shift;
655 XML::Parser::Expat::FreeEncoding($self);
656}
657
658131µs1;
659
660__END__
 
# spent 57µs within XML::Parser::Expat::CORE:ftdir which was called 11 times, avg 5µs/call: # 11 times (57µs+0s) by XML::Parser::BEGIN@13 at line 19, avg 5µs/call
sub XML::Parser::Expat::CORE:ftdir; # opcode
# spent 83.2s (6.75+76.4) within XML::Parser::Expat::ParseString which was called 5000 times, avg 16.6ms/call: # 5000 times (6.75s+76.4s) by XML::Parser::Expat::parse at line 474, avg 16.6ms/call
sub XML::Parser::Expat::ParseString; # xsub
# spent 55.0ms within XML::Parser::Expat::ParserCreate which was called 5000 times, avg 11µs/call: # 5000 times (55.0ms+0s) by XML::Parser::Expat::new at line 66, avg 11µs/call
sub XML::Parser::Expat::ParserCreate; # xsub
# spent 78.2ms within XML::Parser::Expat::ParserFree which was called 5000 times, avg 16µs/call: # 5000 times (78.2ms+0s) by XML::Parser::Expat::DESTROY at line 432, avg 16µs/call
sub XML::Parser::Expat::ParserFree; # xsub
# spent 14.2ms within XML::Parser::Expat::ParserRelease which was called 5000 times, avg 3µs/call: # 5000 times (14.2ms+0s) by XML::Parser::Expat::release at line 427, avg 3µs/call
sub XML::Parser::Expat::ParserRelease; # xsub
# spent 14.2ms within XML::Parser::Expat::SetAttListDeclHandler which was called 5000 times, avg 3µs/call: # 5000 times (14.2ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetAttListDeclHandler; # xsub
# spent 15.1ms within XML::Parser::Expat::SetCharacterDataHandler which was called 5000 times, avg 3µs/call: # 5000 times (15.1ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetCharacterDataHandler; # xsub
# spent 14.7ms within XML::Parser::Expat::SetCommentHandler which was called 5000 times, avg 3µs/call: # 5000 times (14.7ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetCommentHandler; # xsub
# spent 15.2ms within XML::Parser::Expat::SetDoctypeHandler which was called 5000 times, avg 3µs/call: # 5000 times (15.2ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetDoctypeHandler; # xsub
# spent 14.9ms within XML::Parser::Expat::SetElementDeclHandler which was called 5000 times, avg 3µs/call: # 5000 times (14.9ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetElementDeclHandler; # xsub
# spent 17.2ms within XML::Parser::Expat::SetEndCdataHandler which was called 5000 times, avg 3µs/call: # 5000 times (17.2ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetEndCdataHandler; # xsub
# spent 14.9ms within XML::Parser::Expat::SetEndDoctypeHandler which was called 5000 times, avg 3µs/call: # 5000 times (14.9ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetEndDoctypeHandler; # xsub
# spent 14.0ms within XML::Parser::Expat::SetEndElementHandler which was called 5000 times, avg 3µs/call: # 5000 times (14.0ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetEndElementHandler; # xsub
# spent 14.0ms within XML::Parser::Expat::SetEntityDeclHandler which was called 5000 times, avg 3µs/call: # 5000 times (14.0ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetEntityDeclHandler; # xsub
# spent 15.5ms within XML::Parser::Expat::SetExternalEntityRefHandler which was called 5000 times, avg 3µs/call: # 5000 times (15.5ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetExternalEntityRefHandler; # xsub
# spent 14.8ms within XML::Parser::Expat::SetNotationDeclHandler which was called 5000 times, avg 3µs/call: # 5000 times (14.8ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetNotationDeclHandler; # xsub
# spent 15.5ms within XML::Parser::Expat::SetProcessingInstructionHandler which was called 5000 times, avg 3µs/call: # 5000 times (15.5ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetProcessingInstructionHandler; # xsub
# spent 14.7ms within XML::Parser::Expat::SetStartCdataHandler which was called 5000 times, avg 3µs/call: # 5000 times (14.7ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetStartCdataHandler; # xsub
# spent 14.9ms within XML::Parser::Expat::SetStartElementHandler which was called 5000 times, avg 3µs/call: # 5000 times (14.9ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetStartElementHandler; # xsub
# spent 16.7ms within XML::Parser::Expat::SetUnparsedEntityDeclHandler which was called 5000 times, avg 3µs/call: # 5000 times (16.7ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetUnparsedEntityDeclHandler; # xsub
# spent 14.9ms within XML::Parser::Expat::SetXMLDeclHandler which was called 5000 times, avg 3µs/call: # 5000 times (14.9ms+0s) by XML::Parser::Expat::setHandlers at line 125, avg 3µs/call
sub XML::Parser::Expat::SetXMLDeclHandler; # xsub
# spent 94µs within XML::Parser::Expat::bootstrap which was called: # once (94µs+0s) by DynaLoader::bootstrap at line 215 of DynaLoader.pm
sub XML::Parser::Expat::bootstrap; # xsub