Filename | /usr/share/perl/5.20/Tie/Hash.pm |
Statements | Executed 7 statements in 682µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 15µs | 53µs | BEGIN@5 | Tie::Hash::
1 | 1 | 1 | 8µs | 90µs | BEGIN@6 | Tie::Hash::
1 | 1 | 1 | 3µs | 3µs | TIEHASH | Tie::StdHash::
0 | 0 | 0 | 0s | 0s | CLEAR | Tie::ExtraHash::
0 | 0 | 0 | 0s | 0s | DELETE | Tie::ExtraHash::
0 | 0 | 0 | 0s | 0s | EXISTS | Tie::ExtraHash::
0 | 0 | 0 | 0s | 0s | FETCH | Tie::ExtraHash::
0 | 0 | 0 | 0s | 0s | FIRSTKEY | Tie::ExtraHash::
0 | 0 | 0 | 0s | 0s | NEXTKEY | Tie::ExtraHash::
0 | 0 | 0 | 0s | 0s | SCALAR | Tie::ExtraHash::
0 | 0 | 0 | 0s | 0s | STORE | Tie::ExtraHash::
0 | 0 | 0 | 0s | 0s | TIEHASH | Tie::ExtraHash::
0 | 0 | 0 | 0s | 0s | CLEAR | Tie::Hash::
0 | 0 | 0 | 0s | 0s | EXISTS | Tie::Hash::
0 | 0 | 0 | 0s | 0s | TIEHASH | Tie::Hash::
0 | 0 | 0 | 0s | 0s | new | Tie::Hash::
0 | 0 | 0 | 0s | 0s | CLEAR | Tie::StdHash::
0 | 0 | 0 | 0s | 0s | DELETE | Tie::StdHash::
0 | 0 | 0 | 0s | 0s | EXISTS | Tie::StdHash::
0 | 0 | 0 | 0s | 0s | FETCH | Tie::StdHash::
0 | 0 | 0 | 0s | 0s | FIRSTKEY | Tie::StdHash::
0 | 0 | 0 | 0s | 0s | NEXTKEY | Tie::StdHash::
0 | 0 | 0 | 0s | 0s | SCALAR | Tie::StdHash::
0 | 0 | 0 | 0s | 0s | STORE | Tie::StdHash::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Tie::Hash; | ||||
2 | |||||
3 | 1 | 400ns | our $VERSION = '1.05'; | ||
4 | |||||
5 | 2 | 30µs | 2 | 91µs | # spent 53µs (15+38) within Tie::Hash::BEGIN@5 which was called:
# once (15µs+38µs) by C4::Context::BEGIN@105 at line 5 # spent 53µs making 1 call to Tie::Hash::BEGIN@5
# spent 38µs making 1 call to Exporter::import |
6 | 2 | 643µs | 2 | 171µs | # spent 90µs (8+81) within Tie::Hash::BEGIN@6 which was called:
# once (8µs+81µs) by C4::Context::BEGIN@105 at line 6 # spent 90µs making 1 call to Tie::Hash::BEGIN@6
# spent 81µs making 1 call to warnings::register::import |
7 | |||||
8 | sub new { | ||||
9 | my $pkg = shift; | ||||
10 | $pkg->TIEHASH(@_); | ||||
11 | } | ||||
12 | |||||
13 | # Grandfather "new" | ||||
14 | |||||
15 | sub TIEHASH { | ||||
16 | my $pkg = shift; | ||||
17 | my $pkg_new = $pkg -> can ('new'); | ||||
18 | |||||
19 | if ($pkg_new and $pkg ne __PACKAGE__) { | ||||
20 | my $my_new = __PACKAGE__ -> can ('new'); | ||||
21 | if ($pkg_new == $my_new) { | ||||
22 | # | ||||
23 | # Prevent recursion | ||||
24 | # | ||||
25 | croak "$pkg must define either a TIEHASH() or a new() method"; | ||||
26 | } | ||||
27 | |||||
28 | warnings::warnif ("WARNING: calling ${pkg}->new since " . | ||||
29 | "${pkg}->TIEHASH is missing"); | ||||
30 | $pkg -> new (@_); | ||||
31 | } | ||||
32 | else { | ||||
33 | croak "$pkg doesn't define a TIEHASH method"; | ||||
34 | } | ||||
35 | } | ||||
36 | |||||
37 | sub EXISTS { | ||||
38 | my $pkg = ref $_[0]; | ||||
39 | croak "$pkg doesn't define an EXISTS method"; | ||||
40 | } | ||||
41 | |||||
42 | sub CLEAR { | ||||
43 | my $self = shift; | ||||
44 | my $key = $self->FIRSTKEY(@_); | ||||
45 | my @keys; | ||||
46 | |||||
47 | while (defined $key) { | ||||
48 | push @keys, $key; | ||||
49 | $key = $self->NEXTKEY(@_, $key); | ||||
50 | } | ||||
51 | foreach $key (@keys) { | ||||
52 | $self->DELETE(@_, $key); | ||||
53 | } | ||||
54 | } | ||||
55 | |||||
56 | # The Tie::StdHash package implements standard perl hash behaviour. | ||||
57 | # It exists to act as a base class for classes which only wish to | ||||
58 | # alter some parts of their behaviour. | ||||
59 | |||||
60 | package Tie::StdHash; | ||||
61 | # @ISA = qw(Tie::Hash); # would inherit new() only | ||||
62 | |||||
63 | 1 | 6µs | # spent 3µs within Tie::StdHash::TIEHASH which was called:
# once (3µs+0s) by C4::Context::BEGIN@105 at line 480 of POSIX.pm | ||
64 | sub STORE { $_[0]->{$_[1]} = $_[2] } | ||||
65 | sub FETCH { $_[0]->{$_[1]} } | ||||
66 | sub FIRSTKEY { my $a = scalar keys %{$_[0]}; each %{$_[0]} } | ||||
67 | sub NEXTKEY { each %{$_[0]} } | ||||
68 | sub EXISTS { exists $_[0]->{$_[1]} } | ||||
69 | sub DELETE { delete $_[0]->{$_[1]} } | ||||
70 | sub CLEAR { %{$_[0]} = () } | ||||
71 | sub SCALAR { scalar %{$_[0]} } | ||||
72 | |||||
73 | package Tie::ExtraHash; | ||||
74 | |||||
75 | sub TIEHASH { my $p = shift; bless [{}, @_], $p } | ||||
76 | sub STORE { $_[0][0]{$_[1]} = $_[2] } | ||||
77 | sub FETCH { $_[0][0]{$_[1]} } | ||||
78 | sub FIRSTKEY { my $a = scalar keys %{$_[0][0]}; each %{$_[0][0]} } | ||||
79 | sub NEXTKEY { each %{$_[0][0]} } | ||||
80 | sub EXISTS { exists $_[0][0]->{$_[1]} } | ||||
81 | sub DELETE { delete $_[0][0]->{$_[1]} } | ||||
82 | sub CLEAR { %{$_[0][0]} = () } | ||||
83 | sub SCALAR { scalar %{$_[0][0]} } | ||||
84 | |||||
85 | 1 | 3µs | 1; |