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