Filename | /usr/lib/x86_64-linux-gnu/perl5/5.20/XML/LibXML/Literal.pm |
Statements | Executed 14 statements in 856µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 9µs | 36µs | BEGIN@22 | XML::LibXML::Literal::
1 | 1 | 1 | 9µs | 9µs | BEGIN@12 | XML::LibXML::Literal::
1 | 1 | 1 | 6µs | 16µs | BEGIN@15 | XML::LibXML::Literal::
1 | 1 | 1 | 6µs | 6µs | BEGIN@13 | XML::LibXML::Literal::
1 | 1 | 1 | 6µs | 10µs | BEGIN@16 | XML::LibXML::Literal::
1 | 1 | 1 | 6µs | 23µs | BEGIN@18 | XML::LibXML::Literal::
0 | 0 | 0 | 0s | 0s | as_string | XML::LibXML::Literal::
0 | 0 | 0 | 0s | 0s | as_xml | XML::LibXML::Literal::
0 | 0 | 0 | 0s | 0s | cmp | XML::LibXML::Literal::
0 | 0 | 0 | 0s | 0s | evaluate | XML::LibXML::Literal::
0 | 0 | 0 | 0s | 0s | new | XML::LibXML::Literal::
0 | 0 | 0 | 0s | 0s | string_value | XML::LibXML::Literal::
0 | 0 | 0 | 0s | 0s | to_boolean | XML::LibXML::Literal::
0 | 0 | 0 | 0s | 0s | to_literal | XML::LibXML::Literal::
0 | 0 | 0 | 0s | 0s | to_number | XML::LibXML::Literal::
0 | 0 | 0 | 0s | 0s | value | XML::LibXML::Literal::
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 | |||||
10 | package XML::LibXML::Literal; | ||||
11 | |||||
12 | 2 | 23µs | 1 | 9µs | # spent 9µs within XML::LibXML::Literal::BEGIN@12 which was called:
# once (9µs+0s) by XML::LibXML::Number::BEGIN@12 at line 12 # spent 9µs making 1 call to XML::LibXML::Literal::BEGIN@12 |
13 | 2 | 22µs | 1 | 6µs | # spent 6µs within XML::LibXML::Literal::BEGIN@13 which was called:
# once (6µs+0s) by XML::LibXML::Number::BEGIN@12 at line 13 # spent 6µs making 1 call to XML::LibXML::Literal::BEGIN@13 |
14 | |||||
15 | 2 | 20µs | 2 | 26µs | # spent 16µs (6+10) within XML::LibXML::Literal::BEGIN@15 which was called:
# once (6µs+10µs) by XML::LibXML::Number::BEGIN@12 at line 15 # spent 16µs making 1 call to XML::LibXML::Literal::BEGIN@15
# spent 10µs making 1 call to strict::import |
16 | 2 | 22µs | 2 | 14µs | # spent 10µs (6+4) within XML::LibXML::Literal::BEGIN@16 which was called:
# once (6µs+4µs) by XML::LibXML::Number::BEGIN@12 at line 16 # spent 10µs making 1 call to XML::LibXML::Literal::BEGIN@16
# spent 4µs making 1 call to warnings::import |
17 | |||||
18 | 2 | 45µs | 2 | 40µs | # spent 23µs (6+17) within XML::LibXML::Literal::BEGIN@18 which was called:
# once (6µs+17µs) by XML::LibXML::Number::BEGIN@12 at line 18 # spent 23µs making 1 call to XML::LibXML::Literal::BEGIN@18
# spent 17µs making 1 call to vars::import |
19 | 1 | 300ns | $VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE | ||
20 | |||||
21 | use overload | ||||
22 | 1 | 6µs | 1 | 26µs | # spent 36µs (9+26) within XML::LibXML::Literal::BEGIN@22 which was called:
# once (9µs+26µs) by XML::LibXML::Number::BEGIN@12 at line 23 # spent 26µs making 1 call to overload::import |
23 | 1 | 715µs | 1 | 36µs | 'cmp' => \&cmp; # spent 36µs making 1 call to XML::LibXML::Literal::BEGIN@22 |
24 | |||||
25 | sub new { | ||||
26 | my $class = shift; | ||||
27 | my ($string) = @_; | ||||
28 | |||||
29 | # $string =~ s/"/"/g; | ||||
30 | # $string =~ s/'/'/g; | ||||
31 | |||||
32 | bless \$string, $class; | ||||
33 | } | ||||
34 | |||||
35 | sub as_string { | ||||
36 | my $self = shift; | ||||
37 | my $string = $$self; | ||||
38 | $string =~ s/'/'/g; | ||||
39 | return "'$string'"; | ||||
40 | } | ||||
41 | |||||
42 | sub as_xml { | ||||
43 | my $self = shift; | ||||
44 | my $string = $$self; | ||||
45 | return "<Literal>$string</Literal>\n"; | ||||
46 | } | ||||
47 | |||||
48 | sub value { | ||||
49 | my $self = shift; | ||||
50 | $$self; | ||||
51 | } | ||||
52 | |||||
53 | sub cmp { | ||||
54 | my $self = shift; | ||||
55 | my ($cmp, $swap) = @_; | ||||
56 | if ($swap) { | ||||
57 | return $cmp cmp $$self; | ||||
58 | } | ||||
59 | return $$self cmp $cmp; | ||||
60 | } | ||||
61 | |||||
62 | sub evaluate { | ||||
63 | my $self = shift; | ||||
64 | $self; | ||||
65 | } | ||||
66 | |||||
67 | sub to_boolean { | ||||
68 | my $self = shift; | ||||
69 | return (length($$self) > 0) ? XML::LibXML::Boolean->True : XML::LibXML::Boolean->False; | ||||
70 | } | ||||
71 | |||||
72 | sub to_number { return XML::LibXML::Number->new($_[0]->value); } | ||||
73 | sub to_literal { return $_[0]; } | ||||
74 | |||||
75 | sub string_value { return $_[0]->value; } | ||||
76 | |||||
77 | 1 | 2µs | 1; | ||
78 | __END__ |