line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
5
|
#line 1 |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
3
|
|
|
|
|
|
|
use warnings; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
12
|
package Test::Deep::Cache::Simple; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
6
|
|
|
|
|
|
|
use Carp qw( confess ); |
7
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
206
|
|
8
|
|
|
|
|
|
|
use Scalar::Util qw( refaddr ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN |
11
|
1
|
50
|
|
1
|
|
5
|
{ |
12
|
|
|
|
|
|
|
if (grep /^weaken$/, @Scalar::Util::EXPORT_FAIL) |
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
# we're running on a version of perl that has no weak refs, so we |
15
|
0
|
|
|
|
|
0
|
# just install a no-op sub for weaken instead of importing it |
|
0
|
|
|
|
|
0
|
|
16
|
|
|
|
|
|
|
*weaken = sub {}; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
else |
19
|
1
|
|
|
|
|
515
|
{ |
20
|
|
|
|
|
|
|
Scalar::Util->import('weaken'); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new |
25
|
40
|
|
|
40
|
0
|
48
|
{ |
26
|
|
|
|
|
|
|
my $pkg = shift; |
27
|
40
|
|
|
|
|
83
|
|
28
|
|
|
|
|
|
|
my $self = bless {}, $pkg; |
29
|
40
|
|
|
|
|
134
|
|
30
|
|
|
|
|
|
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub add |
34
|
28
|
|
|
28
|
0
|
35
|
{ |
35
|
|
|
|
|
|
|
my $self = shift; |
36
|
28
|
|
|
|
|
35
|
|
37
|
|
|
|
|
|
|
my ($d1, $d2) = @_; |
38
|
28
|
|
|
|
|
26
|
{ |
|
28
|
|
|
|
|
75
|
|
39
|
|
|
|
|
|
|
local $SIG{__DIE__}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# cannot weaken read only refs, no harm if we can't as they never |
42
|
28
|
|
|
|
|
40
|
# disappear |
|
28
|
|
|
|
|
57
|
|
43
|
28
|
|
|
|
|
26
|
eval{weaken($d1)}; |
|
28
|
|
|
|
|
93
|
|
44
|
|
|
|
|
|
|
eval{weaken($d2)}; |
45
|
|
|
|
|
|
|
} |
46
|
28
|
|
|
|
|
71
|
|
47
|
|
|
|
|
|
|
$self->{fn_get_key(@_)} = [$d1, $d2]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub cmp |
51
|
68
|
|
|
68
|
0
|
75
|
{ |
52
|
|
|
|
|
|
|
my $self = shift; |
53
|
68
|
|
|
|
|
116
|
|
54
|
68
|
|
|
|
|
120
|
my $key = fn_get_key(@_); |
55
|
|
|
|
|
|
|
my $pair = $self->{$key}; |
56
|
|
|
|
|
|
|
|
57
|
68
|
50
|
33
|
|
|
189
|
# are both weakened refs still valid, if not delete this entry |
58
|
|
|
|
|
|
|
if (ref($pair->[0]) and ref($pair->[1])) |
59
|
0
|
|
|
|
|
0
|
{ |
60
|
|
|
|
|
|
|
return 1; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else |
63
|
68
|
|
|
|
|
92
|
{ |
64
|
68
|
|
|
|
|
265
|
delete $self->{$key}; |
65
|
|
|
|
|
|
|
return 0; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub absorb |
70
|
12
|
|
|
12
|
0
|
14
|
{ |
71
|
|
|
|
|
|
|
my $self = shift; |
72
|
12
|
|
|
|
|
12
|
|
73
|
|
|
|
|
|
|
my $other = shift; |
74
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
48
|
|
75
|
|
|
|
|
|
|
@{$self}{keys %$other} = values %$other; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub fn_get_key |
79
|
96
|
|
|
96
|
0
|
147
|
{ |
|
192
|
|
|
|
|
1682
|
|
80
|
|
|
|
|
|
|
return join(",", sort (map {refaddr($_)} @_)); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
1; |