line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# tied array object that maintains two additional states: |
3
|
|
|
|
|
|
|
# 1. a parallel array where all original entries |
4
|
|
|
|
|
|
|
# are run through &Devel::DumpTrade::dump_scalar |
5
|
|
|
|
|
|
|
# 2. a cache of results from Text::Shorten::shorten_array |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Calls to Devel::DumpTrace::array_repr should not trigger calls |
8
|
|
|
|
|
|
|
# to Text::Shorten::shorten_array unless the array |
9
|
|
|
|
|
|
|
# has been updated since the last shorten_array call. |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Devel::DumpTrace::CachedDisplayedArray; |
13
|
|
|
|
|
|
|
|
14
|
16
|
|
|
16
|
|
82
|
use strict; |
|
16
|
|
|
|
|
29
|
|
|
16
|
|
|
|
|
337
|
|
15
|
16
|
|
|
16
|
|
58
|
use warnings; |
|
16
|
|
|
|
|
25
|
|
|
16
|
|
|
|
|
272
|
|
16
|
16
|
|
|
16
|
|
56
|
use Carp; |
|
16
|
|
|
|
|
25
|
|
|
16
|
|
|
|
|
13088
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.27'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
*dump_scalar = \&Devel::DumpTrace::dump_scalar; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub TIEARRAY { |
23
|
0
|
|
|
0
|
|
0
|
my ($class, @list) = @_; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# ARRAY: the original and primary hash table |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# PARRAY: copy of HASH where all keys and values are |
28
|
|
|
|
|
|
|
# filtered through Devel::DumpTrace::dump_scalar; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# CACHE: store of results from Text::Shorten. Keys are |
31
|
|
|
|
|
|
|
# auxiliary arguments to Text::Shorten::shorten_array, |
32
|
|
|
|
|
|
|
# values are array refs of shorten_array return values. |
33
|
|
|
|
|
|
|
# Cache is cleared when any element of the array |
34
|
|
|
|
|
|
|
# is changed. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $self = { |
37
|
|
|
|
|
|
|
CACHE => {}, |
38
|
|
|
|
|
|
|
ARRAY => [ @list ], |
39
|
0
|
|
|
|
|
0
|
PARRAY => [ map { dump_scalar($_) } @list ] |
|
0
|
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
}; |
41
|
0
|
|
|
|
|
0
|
return bless $self, $class; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub FETCH { |
45
|
0
|
|
|
0
|
|
0
|
my ($self, $index) = @_; |
46
|
0
|
|
|
|
|
0
|
return $self->{ARRAY}[$index]; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub STORE { |
50
|
0
|
|
|
0
|
|
0
|
my ($self, $index, $value) = @_; |
51
|
0
|
|
|
|
|
0
|
$self->clear_cache; |
52
|
0
|
|
|
|
|
0
|
my $old = $self->{ARRAY}[$index]; |
53
|
0
|
|
|
|
|
0
|
$self->{ARRAY}[$index] = $value; |
54
|
0
|
|
|
|
|
0
|
$self->{PARRAY}[$index] = dump_scalar($value); |
55
|
0
|
|
|
|
|
0
|
return $old; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub FETCHSIZE { |
59
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
60
|
0
|
|
|
|
|
0
|
return scalar @{$self->{ARRAY}}; |
|
0
|
|
|
|
|
0
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub STORESIZE { |
64
|
0
|
|
|
0
|
|
0
|
my ($self, $newcount) = @_; |
65
|
0
|
|
|
|
|
0
|
my $oldcount = $self->FETCHSIZE(); |
66
|
0
|
0
|
|
|
|
0
|
if ($newcount > $oldcount) { |
|
|
0
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
$self->clear_cache; |
68
|
0
|
|
|
|
|
0
|
$self->STORE($_, undef) for $oldcount .. $newcount-1; |
69
|
|
|
|
|
|
|
} elsif ($newcount < $oldcount) { |
70
|
0
|
|
|
|
|
0
|
$self->clear_cache; |
71
|
0
|
|
|
|
|
0
|
$self->POP() for $newcount .. $oldcount-1; |
72
|
|
|
|
|
|
|
} |
73
|
0
|
|
|
|
|
0
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub EXTEND { |
77
|
0
|
|
|
0
|
|
0
|
return; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub DELETE { |
81
|
0
|
|
|
0
|
|
0
|
my ($self, $index) = @_; |
82
|
0
|
|
|
|
|
0
|
$self->clear_cache; |
83
|
0
|
|
|
|
|
0
|
return $self->STORE($index, undef); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub CLEAR { |
87
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
88
|
0
|
|
|
|
|
0
|
$self->clear_cache; |
89
|
0
|
|
|
|
|
0
|
$self->{PARRAY} = []; |
90
|
0
|
|
|
|
|
0
|
$self->{ARRAY} = []; |
91
|
0
|
|
|
|
|
0
|
return; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub EXISTS { |
95
|
0
|
|
|
0
|
|
0
|
my ($self, $index) = @_; |
96
|
0
|
|
|
|
|
0
|
return exists $self->{ARRAY}[$index]; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub PUSH { |
100
|
0
|
|
|
0
|
|
0
|
my ($self, @list) = @_; |
101
|
0
|
0
|
|
|
|
0
|
if (@list > 0) { |
102
|
0
|
|
|
|
|
0
|
$self->clear_cache; |
103
|
|
|
|
|
|
|
} |
104
|
0
|
|
|
|
|
0
|
push @{$self->{ARRAY}}, @list; |
|
0
|
|
|
|
|
0
|
|
105
|
0
|
|
|
|
|
0
|
push @{$self->{PARRAY}}, map { dump_scalar($_) } @list; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
106
|
0
|
|
|
|
|
0
|
return $self->FETCHSIZE(); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub POP { |
110
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
111
|
0
|
0
|
|
|
|
0
|
if (@{$self->{ARRAY}} > 0) { |
|
0
|
|
|
|
|
0
|
|
112
|
0
|
|
|
|
|
0
|
$self->clear_cache; |
113
|
|
|
|
|
|
|
} |
114
|
0
|
|
|
|
|
0
|
pop @{$self->{PARRAY}}; |
|
0
|
|
|
|
|
0
|
|
115
|
0
|
|
|
|
|
0
|
return pop @{$self->{ARRAY}}; |
|
0
|
|
|
|
|
0
|
|
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub SHIFT { |
119
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
120
|
0
|
0
|
|
|
|
0
|
if (@{$self->{ARRAY}} > 0) { |
|
0
|
|
|
|
|
0
|
|
121
|
0
|
|
|
|
|
0
|
$self->clear_cache; |
122
|
|
|
|
|
|
|
} |
123
|
0
|
|
|
|
|
0
|
shift @{$self->{PARRAY}}; |
|
0
|
|
|
|
|
0
|
|
124
|
0
|
|
|
|
|
0
|
return shift @{$self->{ARRAY}}; |
|
0
|
|
|
|
|
0
|
|
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub UNSHIFT { |
128
|
0
|
|
|
0
|
|
0
|
my ($self, @list) = @_; |
129
|
0
|
0
|
|
|
|
0
|
if (@list > 0) { |
130
|
0
|
|
|
|
|
0
|
$self->clear_cache; |
131
|
|
|
|
|
|
|
} |
132
|
0
|
|
|
|
|
0
|
unshift @{$self->{PARRAY}}, map { dump_scalar($_) } @list; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
133
|
0
|
|
|
|
|
0
|
my $result = unshift @{$self->{ARRAY}}, @list; |
|
0
|
|
|
|
|
0
|
|
134
|
0
|
|
|
|
|
0
|
return $result; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub SPLICE { |
138
|
0
|
|
|
0
|
|
0
|
my ($self, $offset, $length, @list) = @_; |
139
|
0
|
|
0
|
|
|
0
|
$offset ||= 0; |
140
|
0
|
|
0
|
|
|
0
|
$length ||= $self->FETCHSIZE() - $offset; |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
0
|
$self->clear_cache; |
143
|
0
|
|
|
|
|
0
|
splice @{$self->{PARRAY}}, $offset, $length, map { dump_scalar($_) } @list; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
144
|
0
|
|
|
|
|
0
|
return splice @{$self->{ARRAY}}, $offset, $length, @list; |
|
0
|
|
|
|
|
0
|
|
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# sub UNTIE { } # not implemented |
148
|
|
|
|
|
|
|
# sub DESTROY { } # not implemented |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub clear_cache { |
151
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
152
|
0
|
|
|
|
|
0
|
$self->{CACHE} = {}; |
153
|
0
|
|
|
|
|
0
|
return; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub store_cache { |
157
|
0
|
|
|
0
|
0
|
0
|
my ($self, $key, $value) = @_; |
158
|
0
|
|
|
|
|
0
|
$self->{CACHE}{$key} = $value; |
159
|
0
|
|
|
|
|
0
|
return; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub get_cache { |
163
|
0
|
|
|
0
|
0
|
0
|
my ($self, $key) = @_; |
164
|
0
|
|
|
|
|
0
|
return $self->{CACHE}{$key}; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub is { |
168
|
186
|
|
|
186
|
0
|
295
|
my ($pkg, $arrayref) = @_; |
169
|
186
|
|
33
|
|
|
691
|
return tied(@$arrayref) && ref(tied(@$arrayref)) eq $pkg; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |