line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
40
|
|
|
40
|
|
257
|
use strict; |
|
40
|
|
|
|
|
81
|
|
|
40
|
|
|
|
|
1119
|
|
2
|
40
|
|
|
40
|
|
202
|
use warnings; |
|
40
|
|
|
|
|
77
|
|
|
40
|
|
|
|
|
1750
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Test::Deep::Cache::Simple 1.202; |
5
|
|
|
|
|
|
|
|
6
|
40
|
|
|
40
|
|
245
|
use Carp qw( confess ); |
|
40
|
|
|
|
|
84
|
|
|
40
|
|
|
|
|
2076
|
|
7
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
256
|
use Scalar::Util qw( refaddr ); |
|
40
|
|
|
|
|
85
|
|
|
40
|
|
|
|
|
4945
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN |
11
|
|
|
|
|
|
|
{ |
12
|
40
|
50
|
|
40
|
|
354
|
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
|
|
|
|
|
|
|
# just install a no-op sub for weaken instead of importing it |
16
|
0
|
|
|
|
|
0
|
*weaken = sub {}; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
else |
19
|
|
|
|
|
|
|
{ |
20
|
40
|
|
|
|
|
14809
|
Scalar::Util->import('weaken'); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new |
25
|
|
|
|
|
|
|
{ |
26
|
2696
|
|
|
2696
|
0
|
3818
|
my $pkg = shift; |
27
|
|
|
|
|
|
|
|
28
|
2696
|
|
|
|
|
4120
|
my $self = bless {}, $pkg; |
29
|
|
|
|
|
|
|
|
30
|
2696
|
|
|
|
|
6580
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub add |
34
|
|
|
|
|
|
|
{ |
35
|
1137
|
|
|
1137
|
0
|
1696
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
1137
|
|
|
|
|
2055
|
my ($d1, $d2) = @_; |
38
|
|
|
|
|
|
|
{ |
39
|
1137
|
|
|
|
|
1551
|
local $SIG{__DIE__}; |
|
1137
|
|
|
|
|
3487
|
|
40
|
|
|
|
|
|
|
|
41
|
1137
|
|
|
|
|
1822
|
local $@; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# cannot weaken read only refs, no harm if we can't as they never |
44
|
|
|
|
|
|
|
# disappear |
45
|
1137
|
|
|
|
|
1980
|
eval{weaken($d1)}; |
|
1137
|
|
|
|
|
2421
|
|
46
|
1137
|
|
|
|
|
1522
|
eval{weaken($d2)}; |
|
1137
|
|
|
|
|
4119
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
1137
|
|
|
|
|
3043
|
$self->{fn_get_key(@_)} = [$d1, $d2]; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub cmp |
53
|
|
|
|
|
|
|
{ |
54
|
2506
|
|
|
2506
|
0
|
3616
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
2506
|
|
|
|
|
4125
|
my $key = fn_get_key(@_); |
57
|
2506
|
|
|
|
|
5236
|
my $pair = $self->{$key}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# are both weakened refs still valid, if not delete this entry |
60
|
2506
|
100
|
66
|
|
|
6075
|
if (ref($pair->[0]) and ref($pair->[1])) |
61
|
|
|
|
|
|
|
{ |
62
|
40
|
|
|
|
|
164
|
return 1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else |
65
|
|
|
|
|
|
|
{ |
66
|
2466
|
|
|
|
|
3657
|
delete $self->{$key}; |
67
|
2466
|
|
|
|
|
7116
|
return 0; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub absorb |
72
|
|
|
|
|
|
|
{ |
73
|
300
|
|
|
300
|
0
|
445
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
300
|
|
|
|
|
441
|
my $other = shift; |
76
|
|
|
|
|
|
|
|
77
|
300
|
|
|
|
|
613
|
@{$self}{keys %$other} = values %$other; |
|
300
|
|
|
|
|
888
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub fn_get_key |
81
|
|
|
|
|
|
|
{ |
82
|
3643
|
|
|
3643
|
0
|
6097
|
return join(",", sort (map {refaddr($_)} @_)); |
|
7286
|
|
|
|
|
22458
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |