← 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:49 2015

Filename/usr/lib/x86_64-linux-gnu/perl5/5.20/XML/LibXML/NodeList.pm
StatementsExecuted 16 statements in 1.69ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111933µs3.69msXML::LibXML::NodeList::::BEGIN@15XML::LibXML::NodeList::BEGIN@15
11112µs23µsXML::LibXML::NodeList::::BEGIN@12XML::LibXML::NodeList::BEGIN@12
11110µs29µsXML::LibXML::NodeList::::BEGIN@23XML::LibXML::NodeList::BEGIN@23
1117µs11µsXML::LibXML::NodeList::::BEGIN@13XML::LibXML::NodeList::BEGIN@13
1116µs21µsXML::LibXML::NodeList::::BEGIN@19XML::LibXML::NodeList::BEGIN@19
1114µs4µsXML::LibXML::NodeList::::BEGIN@16XML::LibXML::NodeList::BEGIN@16
1113µs3µsXML::LibXML::NodeList::::BEGIN@17XML::LibXML::NodeList::BEGIN@17
0000s0sXML::LibXML::NodeList::::__ANON__[:28]XML::LibXML::NodeList::__ANON__[:28]
0000s0sXML::LibXML::NodeList::::__is_codeXML::LibXML::NodeList::__is_code
0000s0sXML::LibXML::NodeList::::appendXML::LibXML::NodeList::append
0000s0sXML::LibXML::NodeList::::foreachXML::LibXML::NodeList::foreach
0000s0sXML::LibXML::NodeList::::get_nodeXML::LibXML::NodeList::get_node
0000s0sXML::LibXML::NodeList::::get_nodelistXML::LibXML::NodeList::get_nodelist
0000s0sXML::LibXML::NodeList::::grepXML::LibXML::NodeList::grep
0000s0sXML::LibXML::NodeList::::itemXML::LibXML::NodeList::item
0000s0sXML::LibXML::NodeList::::iteratorXML::LibXML::NodeList::iterator
0000s0sXML::LibXML::NodeList::::mapXML::LibXML::NodeList::map
0000s0sXML::LibXML::NodeList::::newXML::LibXML::NodeList::new
0000s0sXML::LibXML::NodeList::::new_from_refXML::LibXML::NodeList::new_from_ref
0000s0sXML::LibXML::NodeList::::popXML::LibXML::NodeList::pop
0000s0sXML::LibXML::NodeList::::prependXML::LibXML::NodeList::prepend
0000s0sXML::LibXML::NodeList::::pushXML::LibXML::NodeList::push
0000s0sXML::LibXML::NodeList::::reduceXML::LibXML::NodeList::reduce
0000s0sXML::LibXML::NodeList::::reverseXML::LibXML::NodeList::reverse
0000s0sXML::LibXML::NodeList::::shiftXML::LibXML::NodeList::shift
0000s0sXML::LibXML::NodeList::::sizeXML::LibXML::NodeList::size
0000s0sXML::LibXML::NodeList::::sortXML::LibXML::NodeList::sort
0000s0sXML::LibXML::NodeList::::string_valueXML::LibXML::NodeList::string_value
0000s0sXML::LibXML::NodeList::::to_booleanXML::LibXML::NodeList::to_boolean
0000s0sXML::LibXML::NodeList::::to_literalXML::LibXML::NodeList::to_literal
0000s0sXML::LibXML::NodeList::::to_literal_delimitedXML::LibXML::NodeList::to_literal_delimited
0000s0sXML::LibXML::NodeList::::to_literal_listXML::LibXML::NodeList::to_literal_list
0000s0sXML::LibXML::NodeList::::to_numberXML::LibXML::NodeList::to_number
0000s0sXML::LibXML::NodeList::::unshiftXML::LibXML::NodeList::unshift
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# $Id$
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
10package XML::LibXML::NodeList;
11
12223µs234µs
# spent 23µs (12+11) within XML::LibXML::NodeList::BEGIN@12 which was called: # once (12µs+11µs) by XML::LibXML::BEGIN@27 at line 12
use strict;
# spent 23µs making 1 call to XML::LibXML::NodeList::BEGIN@12 # spent 11µs making 1 call to strict::import
13219µs215µs
# spent 11µs (7+4) within XML::LibXML::NodeList::BEGIN@13 which was called: # once (7µs+4µs) by XML::LibXML::BEGIN@27 at line 13
use warnings;
# spent 11µs making 1 call to XML::LibXML::NodeList::BEGIN@13 # spent 4µs making 1 call to warnings::import
14
152650µs13.69ms
# spent 3.69ms (933µs+2.76) within XML::LibXML::NodeList::BEGIN@15 which was called: # once (933µs+2.76ms) by XML::LibXML::BEGIN@27 at line 15
use XML::LibXML::Boolean;
# spent 3.69ms making 1 call to XML::LibXML::NodeList::BEGIN@15
16218µs14µs
# spent 4µs within XML::LibXML::NodeList::BEGIN@16 which was called: # once (4µs+0s) by XML::LibXML::BEGIN@27 at line 16
use XML::LibXML::Literal;
# spent 4µs making 1 call to XML::LibXML::NodeList::BEGIN@16
17219µs13µs
# spent 3µs within XML::LibXML::NodeList::BEGIN@17 which was called: # once (3µs+0s) by XML::LibXML::BEGIN@27 at line 17
use XML::LibXML::Number;
# spent 3µs making 1 call to XML::LibXML::NodeList::BEGIN@17
18
19272µs236µs
# spent 21µs (6+15) within XML::LibXML::NodeList::BEGIN@19 which was called: # once (6µs+15µs) by XML::LibXML::BEGIN@27 at line 19
use vars qw($VERSION);
# spent 21µs making 1 call to XML::LibXML::NodeList::BEGIN@19 # spent 15µs making 1 call to vars::import
201400ns$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
21
22use overload
23
# spent 29µs (10+19) within XML::LibXML::NodeList::BEGIN@23 which was called: # once (10µs+19µs) by XML::LibXML::BEGIN@27 at line 29
'""' => \&to_literal,
24 'bool' => \&to_boolean,
25 'cmp' => sub {
26 my($aa, $bb, $order) = @_;
27 return ($order ? ("$bb" cmp "$aa") : ("$aa" cmp "$bb"));
28 },
292884µs248µs ;
# spent 29µs making 1 call to XML::LibXML::NodeList::BEGIN@23 # spent 19µs making 1 call to overload::import
30
31sub new {
32 my $class = shift;
33 bless [@_], $class;
34}
35
36sub new_from_ref {
37 my ($class,$array_ref,$reuse) = @_;
38 return bless $reuse ? $array_ref : [@$array_ref], $class;
39}
40
41sub pop {
42 my $self = CORE::shift;
43 CORE::pop @$self;
44}
45
46sub push {
47 my $self = CORE::shift;
48 CORE::push @$self, @_;
49}
50
51sub append {
52 my $self = CORE::shift;
53 my ($nodelist) = @_;
54 CORE::push @$self, $nodelist->get_nodelist;
55}
56
57sub shift {
58 my $self = CORE::shift;
59 CORE::shift @$self;
60}
61
62sub unshift {
63 my $self = CORE::shift;
64 CORE::unshift @$self, @_;
65}
66
67sub prepend {
68 my $self = CORE::shift;
69 my ($nodelist) = @_;
70 CORE::unshift @$self, $nodelist->get_nodelist;
71}
72
73sub size {
74 my $self = CORE::shift;
75 scalar @$self;
76}
77
78sub get_node {
79 # uses array index starting at 1, not 0
80 # this is mainly because of XPath.
81 my $self = CORE::shift;
82 my ($pos) = @_;
83 $self->[$pos - 1];
84}
85
86sub item
87{
88 my ($self, $pos) = @_;
89 return $self->[$pos];
90}
91
92sub get_nodelist {
93 my $self = CORE::shift;
94 @$self;
95}
96
97sub to_boolean {
98 my $self = CORE::shift;
99 return (@$self > 0) ? XML::LibXML::Boolean->True : XML::LibXML::Boolean->False;
100}
101
102# string-value of a nodelist is the string-value of the first node
103sub string_value {
104 my $self = CORE::shift;
105 return '' unless @$self;
106 return $self->[0]->string_value;
107}
108
109sub to_literal {
110 my $self = CORE::shift;
111 return XML::LibXML::Literal->new(
112 join('', CORE::grep {defined $_} CORE::map { $_->string_value } @$self)
113 );
114}
115
116sub to_literal_delimited {
117 my $self = CORE::shift;
118 return XML::LibXML::Literal->new(
119 join(CORE::shift, CORE::grep {defined $_} CORE::map { $_->string_value } @$self)
120 );
121}
122
123sub to_literal_list {
124 my $self = CORE::shift;
125 my @nodes = CORE::map{ XML::LibXML::Literal->new($_->string_value())->value() } @{$self};
126
127 if (wantarray) {
128 return( @nodes );
129 }
130 return( \@nodes );
131}
132
133sub to_number {
134 my $self = CORE::shift;
135 return XML::LibXML::Number->new(
136 $self->to_literal
137 );
138}
139
140sub iterator {
141 warn "this function is obsolete!\nIt was disabled in version 1.54\n";
142 return undef;
143}
144
145sub map {
146 my $self = CORE::shift;
147 my $sub = __is_code(CORE::shift);
148 local $_;
149 my @results = CORE::map { @{[ $sub->($_) ]} } @$self;
150 return unless defined wantarray;
151 return wantarray ? @results : (ref $self)->new(@results);
152}
153
154sub grep {
155 my $self = CORE::shift;
156 my $sub = __is_code(CORE::shift);
157 local $_;
158 my @results = CORE::grep { $sub->($_) } @$self;
159 return unless defined wantarray;
160 return wantarray ? @results : (ref $self)->new(@results);
161}
162
163sub sort {
164 my $self = CORE::shift;
165 my $sub = __is_code(CORE::shift);
166 my @results = CORE::sort { $sub->($a,$b) } @$self;
167 return wantarray ? @results : (ref $self)->new(@results);
168}
169
170sub foreach {
171 my $self = CORE::shift;
172 my $sub = CORE::shift;
173
174 foreach my $item (@$self)
175 {
176 local $_ = $item;
177 $sub->($item);
178 }
179
180 return wantarray ? @$self : $self;
181}
182
183sub reverse {
184 my $self = CORE::shift;
185 my @results = CORE::reverse @$self;
186 return wantarray ? @results : (ref $self)->new(@results);
187}
188
189sub reduce {
190 my $self = CORE::shift;
191 my $sub = __is_code(CORE::shift);
192
193 my @list = @$self;
194 CORE::unshift @list, $_[0] if @_;
195
196 my $a = CORE::shift(@list);
197 foreach my $b (@list)
198 {
199 $a = $sub->($a, $b);
200 }
201 return $a;
202}
203
204sub __is_code {
205 my ($code) = @_;
206
207 if (ref $code eq 'CODE') {
208 return $code;
209 }
210
211 # There are better ways of doing this, but here I've tried to
212 # avoid adding any additional external dependencies.
213 #
214 if (UNIVERSAL::can($code, 'can') # is blessed (sort of)
215 and overload::Overloaded($code) # is overloaded
216 and overload::Method($code, '&{}')) { # overloads '&{}'
217 return $code;
218 }
219
220 # The other possibility is that $code is a coderef, but is
221 # blessed into a class that doesn't overload '&{}'. In which
222 # case... well, I'm stumped!
223
224 die "Not a subroutine reference\n";
225}
226
22712µs1;
228__END__