Filename | /usr/lib/x86_64-linux-gnu/perl-base/Tie/Hash.pm |
Statements | Executed 7 statements in 392µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 9µs | 32µs | BEGIN@5 | Tie::Hash::
1 | 1 | 1 | 4µs | 22µs | BEGIN@6 | Tie::Hash::
1 | 1 | 1 | 1µs | 1µ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 | 200ns | our $VERSION = '1.06'; | ||
4 | |||||
5 | 2 | 18µs | 2 | 54µs | # spent 32µs (9+23) within Tie::Hash::BEGIN@5 which was called:
# once (9µs+23µs) by File::Slurp::BEGIN@16 at line 5 # spent 32µs making 1 call to Tie::Hash::BEGIN@5
# spent 23µs making 1 call to Exporter::import |
6 | 2 | 368µs | 2 | 40µs | # spent 22µs (4+18) within Tie::Hash::BEGIN@6 which was called:
# once (4µs+18µs) by File::Slurp::BEGIN@16 at line 6 # spent 22µs making 1 call to Tie::Hash::BEGIN@6
# spent 18µs making 1 call to warnings::register::import |
7 | |||||
8 | sub new { | ||||
9 | my $pkg = shift; | ||||
10 | $pkg->TIEHASH(@_); | ||||
11 | } | ||||
12 | |||||
13 | # Legacy support for 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 | 3µs | # spent 1µs within Tie::StdHash::TIEHASH which was called:
# once (1µs+0s) by File::Slurp::BEGIN@16 at line 564 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 | 2µs | 1; |