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