| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::Spec::Memoized; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
80381
|
use 5.006_002; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
78
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
117
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
17
|
use File::Spec; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
301
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# constants: |
|
11
|
|
|
|
|
|
|
# curdir, updir, rootdir, devnull |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# already memoized: |
|
14
|
|
|
|
|
|
|
# tmpdir |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
# no memoized (no performance drain): |
|
17
|
|
|
|
|
|
|
# file_name_is_absolute, case_tolerant |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %cache; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# features return a scalar |
|
22
|
|
|
|
|
|
|
foreach my $feature(qw( |
|
23
|
|
|
|
|
|
|
canonpath |
|
24
|
|
|
|
|
|
|
catdir |
|
25
|
|
|
|
|
|
|
catfile |
|
26
|
|
|
|
|
|
|
catpath |
|
27
|
|
|
|
|
|
|
abs2rel |
|
28
|
|
|
|
|
|
|
rel2abs |
|
29
|
|
|
|
|
|
|
)) { |
|
30
|
|
|
|
|
|
|
my $orig = File::Spec->can($feature) or die "Oops: $feature"; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $fs = '$' . $feature; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $memoized = sub :method { |
|
35
|
20
|
|
|
20
|
|
6635
|
my $self = shift; |
|
36
|
20
|
|
66
|
|
|
464
|
return $cache{$fs, @_} ||= $self->$orig(@_); |
|
37
|
|
|
|
|
|
|
}; |
|
38
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
259
|
|
|
39
|
|
|
|
|
|
|
*{$feature} = $memoized; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# features return a list |
|
43
|
|
|
|
|
|
|
foreach my $feature(qw( |
|
44
|
|
|
|
|
|
|
no_upwards |
|
45
|
|
|
|
|
|
|
path |
|
46
|
|
|
|
|
|
|
splitpath |
|
47
|
|
|
|
|
|
|
splitdir |
|
48
|
|
|
|
|
|
|
)) { |
|
49
|
|
|
|
|
|
|
my $orig = File::Spec->can($feature) or die "Oops: $feature"; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $fl = '@' . $feature; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $memoized = sub :method { |
|
54
|
2
|
|
|
2
|
|
6
|
my $self = shift; |
|
55
|
2
|
|
100
|
|
|
3
|
return @{ $cache{$fl, @_} ||= [$self->$orig(@_)] }; |
|
|
2
|
|
|
|
|
62
|
|
|
56
|
|
|
|
|
|
|
}; |
|
57
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
258
|
|
|
58
|
|
|
|
|
|
|
*{$feature} = $memoized; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub flush_cache { |
|
62
|
0
|
|
|
0
|
1
|
|
undef %cache; |
|
63
|
0
|
|
|
|
|
|
return; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
0
|
|
|
sub __cache { \%cache } |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Organize the class hierarchy: |
|
69
|
|
|
|
|
|
|
# File::Spec -> File::Spec::Memoized -> File::Spec::$OS |
|
70
|
|
|
|
|
|
|
# ^^^^^^^^^^^^^^^^^^^^ |
|
71
|
|
|
|
|
|
|
our @ISA = @File::Spec::ISA; |
|
72
|
|
|
|
|
|
|
@File::Spec::ISA = (__PACKAGE__); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
|
75
|
|
|
|
|
|
|
__END__ |