← Index
NYTProf Performance Profile   « line view »
For svc/members/upsert
  Run on Tue Jan 13 11:50:22 2015
Reported on Tue Jan 13 12:09:47 2015

Filename/usr/lib/x86_64-linux-gnu/perl5/5.20/XML/Parser/Expat.pm
StatementsExecuted 344 statements in 5.66ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2114.78ms15.7msXML::Parser::Expat::::ParseStream XML::Parser::Expat::ParseStream (xsub)
10111.05ms1.05msXML::Parser::Expat::::CORE:ftdir XML::Parser::Expat::CORE:ftdir (opcode)
211162µs209µsXML::Parser::Expat::::setHandlers XML::Parser::Expat::setHandlers
11143µs43µsXML::Parser::Expat::::bootstrap XML::Parser::Expat::bootstrap (xsub)
21137µs15.7msXML::Parser::Expat::::parse XML::Parser::Expat::parse
21130µs30µsXML::Parser::Expat::::ParserCreate XML::Parser::Expat::ParserCreate (xsub)
21124µs54µsXML::Parser::Expat::::new XML::Parser::Expat::new
21115µs21µsXML::Parser::Expat::::base XML::Parser::Expat::base
11112µs22µsXML::Parser::Expat::::BEGIN@5 XML::Parser::Expat::BEGIN@5
21111µs11µsXML::Parser::Expat::::ParserFree XML::Parser::Expat::ParserFree (xsub)
11111µs22µsXML::Parser::Expat::::BEGIN@455 XML::Parser::Expat::BEGIN@455
11111µs39µsXML::Parser::ExpatNB::::BEGIN@591 XML::Parser::ExpatNB::BEGIN@591
11110µs36µsXML::Parser::ContentModel::::BEGIN@501XML::Parser::ContentModel::BEGIN@501
2119µs11µsXML::Parser::Expat::::release XML::Parser::Expat::release
2118µs20µsXML::Parser::Expat::::DESTROY XML::Parser::Expat::DESTROY
1118µs25µsXML::Parser::ExpatNB::::BEGIN@590 XML::Parser::ExpatNB::BEGIN@590
1117µs63µsXML::Parser::Expat::::BEGIN@6 XML::Parser::Expat::BEGIN@6
1117µs36µsXML::Parser::Expat::::BEGIN@8 XML::Parser::Expat::BEGIN@8
2114µs4µsXML::Parser::Expat::::SetBase XML::Parser::Expat::SetBase (xsub)
2114µs4µsXML::Parser::Expat::::SetAttListDeclHandler XML::Parser::Expat::SetAttListDeclHandler (xsub)
2114µs4µsXML::Parser::Expat::::SetCommentHandler XML::Parser::Expat::SetCommentHandler (xsub)
2114µs4µsXML::Parser::Expat::::SetNotationDeclHandler XML::Parser::Expat::SetNotationDeclHandler (xsub)
2113µs3µsXML::Parser::Expat::::SetUnparsedEntityDeclHandler XML::Parser::Expat::SetUnparsedEntityDeclHandler (xsub)
2113µs3µsXML::Parser::Expat::::SetElementDeclHandler XML::Parser::Expat::SetElementDeclHandler (xsub)
2113µs3µsXML::Parser::Expat::::SetProcessingInstructionHandler XML::Parser::Expat::SetProcessingInstructionHandler (xsub)
2113µs3µsXML::Parser::Expat::::SetEntityDeclHandler XML::Parser::Expat::SetEntityDeclHandler (xsub)
2113µs3µsXML::Parser::Expat::::SetExternalEntityRefHandler XML::Parser::Expat::SetExternalEntityRefHandler (xsub)
2113µs3µsXML::Parser::Expat::::SetStartCdataHandler XML::Parser::Expat::SetStartCdataHandler (xsub)
2113µs3µsXML::Parser::Expat::::SetCharacterDataHandler XML::Parser::Expat::SetCharacterDataHandler (xsub)
2113µs3µsXML::Parser::Expat::::SetXMLDeclHandler XML::Parser::Expat::SetXMLDeclHandler (xsub)
2113µs3µsXML::Parser::Expat::::SetEndDoctypeHandler XML::Parser::Expat::SetEndDoctypeHandler (xsub)
2112µs2µsXML::Parser::Expat::::SetEndCdataHandler XML::Parser::Expat::SetEndCdataHandler (xsub)
2112µs2µsXML::Parser::Expat::::GetBase XML::Parser::Expat::GetBase (xsub)
2112µs2µsXML::Parser::Expat::::SetDoctypeHandler XML::Parser::Expat::SetDoctypeHandler (xsub)
2112µs2µsXML::Parser::Expat::::SetEndElementHandler XML::Parser::Expat::SetEndElementHandler (xsub)
2112µs2µsXML::Parser::Expat::::SetStartElementHandler XML::Parser::Expat::SetStartElementHandler (xsub)
2112µs2µsXML::Parser::Expat::::ParserRelease XML::Parser::Expat::ParserRelease (xsub)
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::::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
3111µsrequire 5.004;
4
5231µs232µs
# spent 22µs (12+10) within XML::Parser::Expat::BEGIN@5 which was called: # once (12µs+10µs) by XML::Parser::BEGIN@17 at line 5
use strict;
# spent 22µs making 1 call to XML::Parser::Expat::BEGIN@5 # spent 10µs making 1 call to strict::import
613µs157µs
# spent 63µs (7+57) within XML::Parser::Expat::BEGIN@6 which was called: # once (7µs+57µs) by XML::Parser::BEGIN@17 at line 7
use vars qw($VERSION @ISA %Handler_Setters %Encoding_Table @Encoding_Path
# spent 57µs making 1 call to vars::import
7121µs163µs $have_File_Spec);
# spent 63µs making 1 call to XML::Parser::Expat::BEGIN@6
821.71ms266µs
# spent 36µs (7+30) within XML::Parser::Expat::BEGIN@8 which was called: # once (7µs+30µs) by XML::Parser::BEGIN@17 at line 8
use Carp;
# spent 36µs making 1 call to XML::Parser::Expat::BEGIN@8 # spent 30µs making 1 call to Exporter::import
9
101400nsrequire DynaLoader;
11
1216µs@ISA = qw(DynaLoader);
131200ns$VERSION = "2.41";
14
1511µs$have_File_Spec = $INC{'File/Spec.pm'} || do 'File/Spec.pm';
16
171400ns%Encoding_Table = ();
181900nsif ($have_File_Spec) {
1911.14ms311.09ms @Encoding_Path = (grep(-d $_,
# spent 1.05ms making 10 calls to XML::Parser::Expat::CORE:ftdir, avg 105µs/call # spent 29µs making 10 calls to File::Spec::Unix::catdir, avg 3µs/call # spent 4µs making 10 calls to File::Spec::Unix::canonpath, avg 430ns/call # spent 3µ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
2918µs1906µsbootstrap XML::Parser::Expat $VERSION;
# spent 906µs making 1 call to DynaLoader::bootstrap
30
31110µ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 54µs (24+30) within XML::Parser::Expat::new which was called 2 times, avg 27µs/call: # 2 times (24µs+30µs) by XML::Parser::parse at line 170 of XML/Parser.pm, avg 27µs/call
sub new {
5323µs my ($class, %args) = @_;
5422µs my $self = bless \%args, $_[0];
552900ns $args{_State_} = 0;
5621µs $args{Context} = [];
5721µs $args{Namespaces} ||= 0;
5822µs $args{ErrorMessage} ||= '';
592500ns if ($args{Namespaces}) {
60 $args{Namespace_Table} = {};
61 $args{Namespace_List} = [undef];
62 $args{Prefix_Table} = {};
63 $args{New_Prefixes} = [];
64 }
6521µs $args{_Setters} = \%Handler_Setters;
66240µs230µs $args{Parser} = ParserCreate($self, $args{ProtocolEncoding},
# spent 30µs making 2 calls to XML::Parser::Expat::ParserCreate, avg 15µs/call
67 $args{Namespaces});
6824µs $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 209µs (162+47) within XML::Parser::Expat::setHandlers which was called 2 times, avg 105µs/call: # 2 times (162µs+47µs) by XML::Parser::parse at line 175 of XML/Parser.pm, avg 105µs/call
sub setHandlers {
10524µs my ($self, @handler_pairs) = @_;
106
10721µs croak("Uneven number of arguments to setHandlers method")
108 if (int(@handler_pairs) & 1);
109
1102300ns my @ret;
111
11221µs while (@handler_pairs) {
113326µs my $type = shift @handler_pairs;
114324µs my $handler = shift @handler_pairs;
1153213µs croak "Handler for $type not a Code ref"
116 unless (! defined($handler) or ! $handler or ref($handler) eq 'CODE');
117
1183213µs my $hndl = $self->{_Setters}->{$type};
119
120322µs unless (defined($hndl)) {
121 my @types = sort keys %{$self->{_Setters}};
122 croak("Unknown Expat handler type: $type\n Valid types: @types");
123 }
124
12532138µs3247µs my $old = &$hndl($self->{Parser}, $handler);
# spent 4µs making 2 calls to XML::Parser::Expat::SetAttListDeclHandler, avg 2µs/call # spent 4µs making 2 calls to XML::Parser::Expat::SetCommentHandler, avg 2µs/call # spent 4µs making 2 calls to XML::Parser::Expat::SetNotationDeclHandler, avg 2µs/call # spent 3µs making 2 calls to XML::Parser::Expat::SetUnparsedEntityDeclHandler, avg 2µs/call # spent 3µs making 2 calls to XML::Parser::Expat::SetElementDeclHandler, avg 2µs/call # spent 3µs making 2 calls to XML::Parser::Expat::SetProcessingInstructionHandler, avg 2µs/call # spent 3µs making 2 calls to XML::Parser::Expat::SetEntityDeclHandler, avg 2µs/call # spent 3µs making 2 calls to XML::Parser::Expat::SetExternalEntityRefHandler, avg 2µs/call # spent 3µs making 2 calls to XML::Parser::Expat::SetStartCdataHandler, avg 2µs/call # spent 3µs making 2 calls to XML::Parser::Expat::SetCharacterDataHandler, avg 1µs/call # spent 3µs making 2 calls to XML::Parser::Expat::SetXMLDeclHandler, avg 1µs/call # spent 3µs making 2 calls to XML::Parser::Expat::SetEndDoctypeHandler, avg 1µs/call # spent 2µs making 2 calls to XML::Parser::Expat::SetEndCdataHandler, avg 1µs/call # spent 2µs making 2 calls to XML::Parser::Expat::SetDoctypeHandler, avg 1µs/call # spent 2µs making 2 calls to XML::Parser::Expat::SetEndElementHandler, avg 1µs/call # spent 2µs making 2 calls to XML::Parser::Expat::SetStartElementHandler, avg 800ns/call
1263222µs push (@ret, $type, $old);
127 }
128
12925µs 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
197
# spent 21µs (15+6) within XML::Parser::Expat::base which was called 2 times, avg 11µs/call: # 2 times (15µs+6µs) by XML::Parser::parse at line 177 of XML/Parser.pm, avg 11µs/call
sub base {
1982900ns my ($self, $newbase) = @_;
1992600ns my $p = $self->{Parser};
20027µs22µs my $oldbase = GetBase($p);
# spent 2µs making 2 calls to XML::Parser::Expat::GetBase, avg 1µs/call
201210µs24µs SetBase($p, $newbase) if @_ > 1;
# spent 4µs making 2 calls to XML::Parser::Expat::SetBase, avg 2µs/call
20228µs 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 11µs (9+1) within XML::Parser::Expat::release which was called 2 times, avg 5µs/call: # 2 times (9µs+1µs) by XML::Parser::parse at line 204 of XML/Parser.pm, avg 5µs/call
sub release {
4262700ns my $self = shift;
427211µs22µs ParserRelease($self->{Parser});
# spent 2µs making 2 calls to XML::Parser::Expat::ParserRelease, avg 750ns/call
428}
429
430
# spent 20µs (8+11) within XML::Parser::Expat::DESTROY which was called 2 times, avg 10µs/call: # 2 times (8µs+11µs) by XML::Parser::parse at line 233 of XML/Parser.pm, avg 10µs/call
sub DESTROY {
4312500ns my $self = shift;
432220µs211µs ParserFree($self->{Parser});
# spent 11µs making 2 calls to XML::Parser::Expat::ParserFree, avg 6µs/call
433}
434
435
# spent 15.7ms (37µs+15.7) within XML::Parser::Expat::parse which was called 2 times, avg 7.86ms/call: # 2 times (37µs+15.7ms) by XML::Parser::parse at line 187 of XML/Parser.pm, avg 7.86ms/call
sub parse {
4362500ns my $self = shift;
43722µs my $arg = shift;
43821µs croak "Parse already in progress (Expat)" if $self->{_State_};
4392800ns $self->{_State_} = 1;
4402600ns my $parser = $self->{Parser};
4412200ns my $ioref;
4422500ns my $result = 0;
443
44421µs if (defined $arg) {
44522µs local *@;
44624µs if (ref($arg) and UNIVERSAL::isa($arg, 'IO::Handle')) {
447 $ioref = $arg;
448 } elsif ($] < 5.008 and defined tied($arg)) {
449 require IO::Handle;
450 $ioref = $arg;
451 }
452 else {
45322µs require IO::Handle;
45421µs eval {
4552226µs232µs
# spent 22µs (11+11) within XML::Parser::Expat::BEGIN@455 which was called: # once (11µs+11µs) by XML::Parser::BEGIN@17 at line 455
no strict 'refs';
# spent 22µs making 1 call to XML::Parser::Expat::BEGIN@455 # spent 11µs making 1 call to strict::unimport
45623µs $ioref = *{$arg}{IO} if defined *{$arg};
457 };
458 }
459 }
460
4612800ns if (defined($ioref)) {
4622700ns my $delim = $self->{Stream_Delimiter};
4632300ns my $prev_rs;
46421µs my $ioclass = ref $ioref;
46521µs $ioclass = "IO::Handle" if !length $ioclass;
466
4672400ns $prev_rs = $ioclass->input_record_separator("\n$delim\n")
468 if defined($delim);
469
47021.44ms81426.6ms $result = ParseStream($parser, $ioref, $delim);
# spent 15.7ms making 2 calls to XML::Parser::Expat::ParseStream, avg 7.84ms/call # spent 4.64ms making 142 calls to XML::SAX::Expat::_handle_start, avg 33µs/call # spent 3.91ms making 478 calls to XML::SAX::Expat::_handle_char, avg 8µs/call # spent 2.02ms making 142 calls to XML::SAX::Expat::_handle_end, avg 14µs/call # spent 281µs making 46 calls to XML::SAX::Expat::_handle_comment, avg 6µs/call # spent 57µs making 4 calls to IO::Handle::read, avg 14µs/call
471
47222µs $ioclass->input_record_separator($prev_rs)
473 if defined($delim);
474 } else {
475 $result = ParseString($parser, $arg);
476 }
477
47821µs $self->{_State_} = 2;
47926µs $result or croak $self->{ErrorMessage};
480}
481
482sub parsestring {
483 my $self = shift;
484 $self->parse(@_);
485}
486
487sub parsefile {
488 my $self = shift;
489 croak "Parser has already been used" if $self->{_State_};
490 local(*FILE);
491 open(FILE, $_[0]) or croak "Couldn't open $_[0]:\n$!";
492 binmode(FILE);
493 my $ret = $self->parse(*FILE);
494 close(FILE);
495 $ret;
496}
497
498################################################################
499package #hide from PAUSE
500 XML::Parser::ContentModel;
5012362µs262µs
# spent 36µs (10+26) within XML::Parser::ContentModel::BEGIN@501 which was called: # once (10µs+26µs) by XML::Parser::BEGIN@17 at line 501
use overload '""' => \&asString, 'eq' => \&thiseq;
# spent 36µs making 1 call to XML::Parser::ContentModel::BEGIN@501 # spent 26µs making 1 call to overload::import
502
503sub EMPTY () {1}
504sub ANY () {2}
505sub MIXED () {3}
506sub NAME () {4}
507sub CHOICE () {5}
508sub SEQ () {6}
509
510
511sub isempty {
512 return $_[0]->{Type} == EMPTY;
513}
514
515sub isany {
516 return $_[0]->{Type} == ANY;
517}
518
519sub ismixed {
520 return $_[0]->{Type} == MIXED;
521}
522
523sub isname {
524 return $_[0]->{Type} == NAME;
525}
526
527sub name {
528 return $_[0]->{Tag};
529}
530
531sub ischoice {
532 return $_[0]->{Type} == CHOICE;
533}
534
535sub isseq {
536 return $_[0]->{Type} == SEQ;
537}
538
539sub quant {
540 return $_[0]->{Quant};
541}
542
543sub children {
544 my $children = $_[0]->{Children};
545 if (defined $children) {
546 return @$children;
547 }
548 return undef;
549}
550
551sub asString {
552 my ($self) = @_;
553 my $ret;
554
555 if ($self->{Type} == NAME) {
556 $ret = $self->{Tag};
557 }
558 elsif ($self->{Type} == EMPTY) {
559 return "EMPTY";
560 }
561 elsif ($self->{Type} == ANY) {
562 return "ANY";
563 }
564 elsif ($self->{Type} == MIXED) {
565 $ret = '(#PCDATA';
566 foreach (@{$self->{Children}}) {
567 $ret .= '|' . $_;
568 }
569 $ret .= ')';
570 }
571 else {
572 my $sep = $self->{Type} == CHOICE ? '|' : ',';
573 $ret = '(' . join($sep, map { $_->asString } @{$self->{Children}}) . ')';
574 }
575
576 $ret .= $self->{Quant} if $self->{Quant};
577 return $ret;
578}
579
580sub thiseq {
581 my $self = shift;
582
583 return $self->asString eq $_[0];
584}
585
586################################################################
587package #hide from PAUSE
588 XML::Parser::ExpatNB;
589
590228µs242µs
# spent 25µs (8+17) within XML::Parser::ExpatNB::BEGIN@590 which was called: # once (8µs+17µs) by XML::Parser::BEGIN@17 at line 590
use vars qw(@ISA);
# spent 25µs making 1 call to XML::Parser::ExpatNB::BEGIN@590 # spent 17µs making 1 call to vars::import
5912289µs266µs
# spent 39µs (11+28) within XML::Parser::ExpatNB::BEGIN@591 which was called: # once (11µs+28µs) by XML::Parser::BEGIN@17 at line 591
use Carp;
# spent 39µs making 1 call to XML::Parser::ExpatNB::BEGIN@591 # spent 28µs making 1 call to Exporter::import
592
59315µs@ISA = qw(XML::Parser::Expat);
594
595sub parse {
596 my $self = shift;
597 my $class = ref($self);
598 croak "parse method not supported in $class";
599}
600
601sub parsestring {
602 my $self = shift;
603 my $class = ref($self);
604 croak "parsestring method not supported in $class";
605}
606
607sub parsefile {
608 my $self = shift;
609 my $class = ref($self);
610 croak "parsefile method not supported in $class";
611}
612
613sub parse_more {
614 my ($self, $data) = @_;
615
616 $self->{_State_} = 1;
617 my $ret = XML::Parser::Expat::ParsePartial($self->{Parser}, $data);
618
619 croak $self->{ErrorMessage} unless $ret;
620}
621
622sub parse_done {
623 my $self = shift;
624
625 my $ret = XML::Parser::Expat::ParseDone($self->{Parser});
626 unless ($ret) {
627 my $msg = $self->{ErrorMessage};
628 $self->release;
629 croak $msg;
630 }
631
632 $self->{_State_} = 2;
633
634 my $result = $ret;
635 my @result = ();
636 my $final = $self->{FinalHandler};
637 if (defined $final) {
638 if (wantarray) {
639 @result = &$final($self);
640 }
641 else {
642 $result = &$final($self);
643 }
644 }
645
646 $self->release;
647
648 return unless defined wantarray;
649 return wantarray ? @result : $result;
650}
651
652################################################################
653
654package #hide from PAUSE
655 XML::Parser::Encinfo;
656
657sub DESTROY {
658 my $self = shift;
659 XML::Parser::Expat::FreeEncoding($self);
660}
661
662111µs1;
663
664__END__
 
# spent 1.05ms within XML::Parser::Expat::CORE:ftdir which was called 10 times, avg 105µs/call: # 10 times (1.05ms+0s) by XML::Parser::BEGIN@17 at line 19, avg 105µs/call
sub XML::Parser::Expat::CORE:ftdir; # opcode
# spent 2µs within XML::Parser::Expat::GetBase which was called 2 times, avg 1µs/call: # 2 times (2µs+0s) by XML::Parser::Expat::base at line 200, avg 1µs/call
sub XML::Parser::Expat::GetBase; # xsub
# spent 15.7ms (4.78+10.9) within XML::Parser::Expat::ParseStream which was called 2 times, avg 7.84ms/call: # 2 times (4.78ms+10.9ms) by XML::Parser::Expat::parse at line 470, avg 7.84ms/call
sub XML::Parser::Expat::ParseStream; # xsub
# spent 30µs within XML::Parser::Expat::ParserCreate which was called 2 times, avg 15µs/call: # 2 times (30µs+0s) by XML::Parser::Expat::new at line 66, avg 15µs/call
sub XML::Parser::Expat::ParserCreate; # xsub
# spent 11µs within XML::Parser::Expat::ParserFree which was called 2 times, avg 6µs/call: # 2 times (11µs+0s) by XML::Parser::Expat::DESTROY at line 432, avg 6µs/call
sub XML::Parser::Expat::ParserFree; # xsub
# spent 2µs within XML::Parser::Expat::ParserRelease which was called 2 times, avg 750ns/call: # 2 times (2µs+0s) by XML::Parser::Expat::release at line 427, avg 750ns/call
sub XML::Parser::Expat::ParserRelease; # xsub
# spent 4µs within XML::Parser::Expat::SetAttListDeclHandler which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 2µs/call
sub XML::Parser::Expat::SetAttListDeclHandler; # xsub
# spent 4µs within XML::Parser::Expat::SetBase which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by XML::Parser::Expat::base at line 201, avg 2µs/call
sub XML::Parser::Expat::SetBase; # xsub
# spent 3µs within XML::Parser::Expat::SetCharacterDataHandler which was called 2 times, avg 1µs/call: # 2 times (3µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 1µs/call
sub XML::Parser::Expat::SetCharacterDataHandler; # xsub
# spent 4µs within XML::Parser::Expat::SetCommentHandler which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 2µs/call
sub XML::Parser::Expat::SetCommentHandler; # xsub
# spent 2µs within XML::Parser::Expat::SetDoctypeHandler which was called 2 times, avg 1µs/call: # 2 times (2µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 1µs/call
sub XML::Parser::Expat::SetDoctypeHandler; # xsub
# spent 3µs within XML::Parser::Expat::SetElementDeclHandler which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 2µs/call
sub XML::Parser::Expat::SetElementDeclHandler; # xsub
# spent 2µs within XML::Parser::Expat::SetEndCdataHandler which was called 2 times, avg 1µs/call: # 2 times (2µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 1µs/call
sub XML::Parser::Expat::SetEndCdataHandler; # xsub
# spent 3µs within XML::Parser::Expat::SetEndDoctypeHandler which was called 2 times, avg 1µs/call: # 2 times (3µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 1µs/call
sub XML::Parser::Expat::SetEndDoctypeHandler; # xsub
# spent 2µs within XML::Parser::Expat::SetEndElementHandler which was called 2 times, avg 1µs/call: # 2 times (2µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 1µs/call
sub XML::Parser::Expat::SetEndElementHandler; # xsub
# spent 3µs within XML::Parser::Expat::SetEntityDeclHandler which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 2µs/call
sub XML::Parser::Expat::SetEntityDeclHandler; # xsub
# spent 3µs within XML::Parser::Expat::SetExternalEntityRefHandler which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 2µs/call
sub XML::Parser::Expat::SetExternalEntityRefHandler; # xsub
# spent 4µs within XML::Parser::Expat::SetNotationDeclHandler which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 2µs/call
sub XML::Parser::Expat::SetNotationDeclHandler; # xsub
# spent 3µs within XML::Parser::Expat::SetProcessingInstructionHandler which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 2µs/call
sub XML::Parser::Expat::SetProcessingInstructionHandler; # xsub
# spent 3µs within XML::Parser::Expat::SetStartCdataHandler which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 2µs/call
sub XML::Parser::Expat::SetStartCdataHandler; # xsub
# spent 2µs within XML::Parser::Expat::SetStartElementHandler which was called 2 times, avg 800ns/call: # 2 times (2µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 800ns/call
sub XML::Parser::Expat::SetStartElementHandler; # xsub
# spent 3µs within XML::Parser::Expat::SetUnparsedEntityDeclHandler which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 2µs/call
sub XML::Parser::Expat::SetUnparsedEntityDeclHandler; # xsub
# spent 3µs within XML::Parser::Expat::SetXMLDeclHandler which was called 2 times, avg 1µs/call: # 2 times (3µs+0s) by XML::Parser::Expat::setHandlers at line 125, avg 1µs/call
sub XML::Parser::Expat::SetXMLDeclHandler; # xsub
# spent 43µs within XML::Parser::Expat::bootstrap which was called: # once (43µs+0s) by DynaLoader::bootstrap at line 210 of DynaLoader.pm
sub XML::Parser::Expat::bootstrap; # xsub