line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Heap::Simple::Hash; |
2
|
|
|
|
|
|
|
$VERSION = "0.05"; |
3
|
3
|
|
|
3
|
|
20
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
114
|
|
4
|
3
|
|
|
3
|
|
16
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1802
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $key_name = "k0"; |
7
|
|
|
|
|
|
|
my %key_names; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _elements { |
10
|
105
|
|
|
105
|
|
280
|
my ($class, $heap, $name, $elements) = @_; |
11
|
105
|
100
|
|
|
|
558
|
croak "missing key name for $elements->[0]" unless |
12
|
|
|
|
|
|
|
defined($elements->[1]); |
13
|
104
|
|
|
|
|
4643
|
$heap->[0]{index} = $elements->[1]; |
14
|
104
|
100
|
66
|
|
|
1354
|
return $name, $key_names{$heap->[0]{index}} ||= $key_name++ if |
15
|
|
|
|
|
|
|
$elements->[1] =~ /\A[ -~]*\z/; |
16
|
1
|
|
|
|
|
2
|
$heap->[0]{complex} = 1; |
17
|
1
|
|
|
|
|
5
|
return $name; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _ELEMENTS_PREPARE { |
21
|
98
|
100
|
|
98
|
|
1259
|
return shift->[0]{complex} ? "my \$name = \$heap->[0]{index};" : ""; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _KEY { |
25
|
672
|
100
|
|
672
|
|
16576
|
return shift->[0]{complex} ? |
26
|
|
|
|
|
|
|
shift() . "->{\$name}" : shift() . "->{_STRING}" |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _QUICK_KEY { |
30
|
52
|
50
|
|
52
|
|
2783
|
return shift->[0]{complex} ? |
31
|
|
|
|
|
|
|
shift() . "->{\$heap->[0]{index}}" : shift() . "->{_STRING}" |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub key_name { |
35
|
5
|
|
|
5
|
0
|
2154
|
my $heap = shift; |
36
|
5
|
50
|
|
|
|
25
|
if ($heap->[0]{complex}) { |
37
|
0
|
|
|
|
|
0
|
$heap->_make('sub key_name() { |
38
|
|
|
|
|
|
|
shift->[0]{index}}'); |
39
|
|
|
|
|
|
|
} else { |
40
|
5
|
|
|
|
|
24
|
$heap->_make(qq(sub key_name() { |
41
|
|
|
|
|
|
|
return _STRING; |
42
|
|
|
|
|
|
|
})); |
43
|
|
|
|
|
|
|
} |
44
|
5
|
|
|
|
|
185
|
return $heap->key_name(@_); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub key { |
48
|
36
|
|
|
36
|
0
|
13040
|
my $heap = shift; |
49
|
36
|
100
|
|
|
|
349
|
if ($heap->[0]{complex}) { |
50
|
1
|
|
|
|
|
6
|
$heap->_make('sub key { |
51
|
|
|
|
|
|
|
return $_[1]->{$_[0][0]{index}}}'); |
52
|
|
|
|
|
|
|
} else { |
53
|
35
|
|
|
|
|
143
|
$heap->_make('sub key { |
54
|
|
|
|
|
|
|
return $_[1]->{_STRING}}'); |
55
|
|
|
|
|
|
|
} |
56
|
36
|
|
|
|
|
22444
|
return $heap->key(@_); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub elements { |
60
|
127
|
100
|
|
127
|
0
|
13697
|
return wantarray ? (Hash => shift->[0]{index}) : "Hash"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |