Filename | /usr/lib/perl5/XML/LibXML/NodeList.pm |
Statements | Executed 21 statements in 823µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 613µs | 2.40ms | BEGIN@12 | XML::LibXML::NodeList::
1 | 1 | 1 | 19µs | 24µs | BEGIN@11 | XML::LibXML::NodeList::
1 | 1 | 1 | 15µs | 49µs | BEGIN@20 | XML::LibXML::NodeList::
1 | 1 | 1 | 10µs | 12µs | BEGIN@13 | XML::LibXML::NodeList::
1 | 1 | 1 | 9µs | 10µs | BEGIN@14 | XML::LibXML::NodeList::
1 | 1 | 1 | 8µs | 33µs | BEGIN@16 | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | append | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | get_node | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | get_nodelist | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | iterator | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | new | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | new_from_ref | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | pop | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | prepend | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | push | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | shift | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | size | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | string_value | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | to_boolean | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | to_literal | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | to_number | XML::LibXML::NodeList::
0 | 0 | 0 | 0s | 0s | unshift | XML::LibXML::NodeList::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # $Id: NodeList.pm 785 2009-07-16 14:17:46Z pajas $ | ||||
2 | # | ||||
3 | # This is free software, you may use it and distribute it under the same terms as | ||||
4 | # Perl itself. | ||||
5 | # | ||||
6 | # Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas | ||||
7 | # | ||||
8 | # | ||||
9 | |||||
10 | package XML::LibXML::NodeList; | ||||
11 | 3 | 45µs | 2 | 29µs | # spent 24µs (19+5) within XML::LibXML::NodeList::BEGIN@11 which was called:
# once (19µs+5µs) by XML::LibXML::BEGIN@24 at line 11 # spent 24µs making 1 call to XML::LibXML::NodeList::BEGIN@11
# spent 5µs making 1 call to strict::import |
12 | 3 | 140µs | 2 | 2.40ms | # spent 2.40ms (613µs+1.78) within XML::LibXML::NodeList::BEGIN@12 which was called:
# once (613µs+1.78ms) by XML::LibXML::BEGIN@24 at line 12 # spent 2.40ms making 1 call to XML::LibXML::NodeList::BEGIN@12
# spent 3µs making 1 call to UNIVERSAL::import |
13 | 3 | 27µs | 2 | 13µs | # spent 12µs (10+2) within XML::LibXML::NodeList::BEGIN@13 which was called:
# once (10µs+2µs) by XML::LibXML::BEGIN@24 at line 13 # spent 12µs making 1 call to XML::LibXML::NodeList::BEGIN@13
# spent 2µs making 1 call to UNIVERSAL::import |
14 | 3 | 26µs | 2 | 12µs | # spent 10µs (9+1) within XML::LibXML::NodeList::BEGIN@14 which was called:
# once (9µs+1µs) by XML::LibXML::BEGIN@24 at line 14 # spent 10µs making 1 call to XML::LibXML::NodeList::BEGIN@14
# spent 1µs making 1 call to UNIVERSAL::import |
15 | |||||
16 | 3 | 50µs | 2 | 59µs | # spent 33µs (8+26) within XML::LibXML::NodeList::BEGIN@16 which was called:
# once (8µs+26µs) by XML::LibXML::BEGIN@24 at line 16 # spent 33µs making 1 call to XML::LibXML::NodeList::BEGIN@16
# spent 26µs making 1 call to vars::import |
17 | 1 | 700ns | $VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE | ||
18 | |||||
19 | use overload | ||||
20 | 1 | 34µs | # spent 49µs (15+34) within XML::LibXML::NodeList::BEGIN@20 which was called:
# once (15µs+34µs) by XML::LibXML::BEGIN@24 at line 22 # spent 34µs making 1 call to overload::import | ||
21 | 'bool' => \&to_boolean, | ||||
22 | 3 | 529µs | 1 | 49µs | ; # spent 49µs making 1 call to XML::LibXML::NodeList::BEGIN@20 |
23 | |||||
24 | sub new { | ||||
25 | my $class = shift; | ||||
26 | bless [@_], $class; | ||||
27 | } | ||||
28 | |||||
29 | sub new_from_ref { | ||||
30 | my ($class,$array_ref,$reuse) = @_; | ||||
31 | return bless $reuse ? $array_ref : [@$array_ref], $class; | ||||
32 | } | ||||
33 | |||||
34 | sub pop { | ||||
35 | my $self = CORE::shift; | ||||
36 | CORE::pop @$self; | ||||
37 | } | ||||
38 | |||||
39 | sub push { | ||||
40 | my $self = CORE::shift; | ||||
41 | CORE::push @$self, @_; | ||||
42 | } | ||||
43 | |||||
44 | sub append { | ||||
45 | my $self = CORE::shift; | ||||
46 | my ($nodelist) = @_; | ||||
47 | CORE::push @$self, $nodelist->get_nodelist; | ||||
48 | } | ||||
49 | |||||
50 | sub shift { | ||||
51 | my $self = CORE::shift; | ||||
52 | CORE::shift @$self; | ||||
53 | } | ||||
54 | |||||
55 | sub unshift { | ||||
56 | my $self = CORE::shift; | ||||
57 | CORE::unshift @$self, @_; | ||||
58 | } | ||||
59 | |||||
60 | sub prepend { | ||||
61 | my $self = CORE::shift; | ||||
62 | my ($nodelist) = @_; | ||||
63 | CORE::unshift @$self, $nodelist->get_nodelist; | ||||
64 | } | ||||
65 | |||||
66 | sub size { | ||||
67 | my $self = CORE::shift; | ||||
68 | scalar @$self; | ||||
69 | } | ||||
70 | |||||
71 | sub get_node { | ||||
72 | # uses array index starting at 1, not 0 | ||||
73 | # this is mainly because of XPath. | ||||
74 | my $self = CORE::shift; | ||||
75 | my ($pos) = @_; | ||||
76 | $self->[$pos - 1]; | ||||
77 | } | ||||
78 | |||||
79 | 1 | 2µs | *item = \&get_node; | ||
80 | |||||
81 | sub get_nodelist { | ||||
82 | my $self = CORE::shift; | ||||
83 | @$self; | ||||
84 | } | ||||
85 | |||||
86 | sub to_boolean { | ||||
87 | my $self = CORE::shift; | ||||
88 | return (@$self > 0) ? XML::LibXML::Boolean->True : XML::LibXML::Boolean->False; | ||||
89 | } | ||||
90 | |||||
91 | # string-value of a nodelist is the string-value of the first node | ||||
92 | sub string_value { | ||||
93 | my $self = CORE::shift; | ||||
94 | return '' unless @$self; | ||||
95 | return $self->[0]->string_value; | ||||
96 | } | ||||
97 | |||||
98 | sub to_literal { | ||||
99 | my $self = CORE::shift; | ||||
100 | return XML::LibXML::Literal->new( | ||||
101 | join('', grep {defined $_} map { $_->string_value } @$self) | ||||
102 | ); | ||||
103 | } | ||||
104 | |||||
105 | sub to_number { | ||||
106 | my $self = CORE::shift; | ||||
107 | return XML::LibXML::Number->new( | ||||
108 | $self->to_literal | ||||
109 | ); | ||||
110 | } | ||||
111 | |||||
112 | sub iterator { | ||||
113 | warn "this function is obsolete!\nIt was disabled in version 1.54\n"; | ||||
114 | return undef; | ||||
115 | } | ||||
116 | |||||
117 | 1 | 4µs | 1; | ||
118 | __END__ |