line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Function::Fallback::CoreOrPP; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
679
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
537
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.07'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $USE_NONCORE_XS_FIRST = 1; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
14
|
|
|
|
|
|
|
clone |
15
|
|
|
|
|
|
|
clone_list |
16
|
|
|
|
|
|
|
unbless |
17
|
|
|
|
|
|
|
uniq |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub clone { |
21
|
0
|
|
|
0
|
1
|
0
|
my $data = shift; |
22
|
0
|
0
|
|
|
|
0
|
goto FALLBACK unless $USE_NONCORE_XS_FIRST; |
23
|
0
|
0
|
|
|
|
0
|
goto FALLBACK unless eval { require Data::Clone; 1 }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
STANDARD: |
26
|
|
|
|
|
|
|
return Data::Clone::clone($data); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
FALLBACK: |
29
|
|
|
|
|
|
|
require Clone::PP; |
30
|
0
|
|
|
|
|
0
|
return Clone::PP::clone($data); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub clone_list { |
34
|
0
|
|
|
0
|
1
|
0
|
map { clone($_) } @_; |
|
0
|
|
|
|
|
0
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _unbless_fallback { |
38
|
3
|
|
|
3
|
|
4
|
my $ref = shift; |
39
|
|
|
|
|
|
|
|
40
|
3
|
|
|
|
|
6
|
my $r = ref($ref); |
41
|
|
|
|
|
|
|
# not a reference |
42
|
3
|
50
|
|
|
|
8
|
return $ref unless $r; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# return if not a blessed ref |
45
|
3
|
50
|
|
|
|
32
|
my ($r2, $r3) = "$ref" =~ /(.+)=(.+?)\(/ |
46
|
|
|
|
|
|
|
or return $ref; |
47
|
|
|
|
|
|
|
|
48
|
3
|
100
|
|
|
|
15
|
if ($r3 eq 'HASH') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
49
|
1
|
|
|
|
|
8
|
return { %$ref }; |
50
|
|
|
|
|
|
|
} elsif ($r3 eq 'ARRAY') { |
51
|
1
|
|
|
|
|
5
|
return [ @$ref ]; |
52
|
|
|
|
|
|
|
} elsif ($r3 eq 'SCALAR') { |
53
|
1
|
|
|
|
|
2
|
return \( my $copy = ${$ref} ); |
|
1
|
|
|
|
|
6
|
|
54
|
|
|
|
|
|
|
} else { |
55
|
0
|
|
|
|
|
0
|
die "Can't handle $ref"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub unbless { |
60
|
3
|
|
|
3
|
1
|
1059
|
my $ref = shift; |
61
|
|
|
|
|
|
|
|
62
|
3
|
50
|
|
|
|
15
|
goto FALLBACK unless $USE_NONCORE_XS_FIRST; |
63
|
0
|
0
|
|
|
|
0
|
goto FALLBACK unless eval { require Acme::Damn; 1 }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
0
|
STANDARD: |
66
|
|
|
|
|
|
|
return Acme::Damn::damn($ref); |
67
|
|
|
|
|
|
|
|
68
|
3
|
|
|
|
|
10
|
FALLBACK: |
69
|
|
|
|
|
|
|
return _unbless_fallback($ref); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub uniq { |
73
|
1
|
50
|
|
1
|
1
|
2118
|
goto FALLBACK unless $USE_NONCORE_XS_FIRST; |
74
|
0
|
0
|
|
|
|
0
|
goto FALLBACK unless eval { require List::MoreUtils; 1 }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
STANDARD: |
77
|
|
|
|
|
|
|
return List::MoreUtils::uniq(@_); |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
2
|
FALLBACK: |
80
|
|
|
|
|
|
|
my %h; |
81
|
1
|
|
|
|
|
3
|
my @res; |
82
|
1
|
|
|
|
|
3
|
for (@_) { |
83
|
6
|
100
|
|
|
|
23
|
push @res, $_ unless $h{$_}++; |
84
|
|
|
|
|
|
|
} |
85
|
1
|
|
|
|
|
9
|
return @res; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
# ABSTRACT: Functions that use non-core XS module but provide pure-Perl/core fallback |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |