line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bitcoin::Crypto::Role::ShallowClone; |
2
|
|
|
|
|
|
|
$Bitcoin::Crypto::Role::ShallowClone::VERSION = '2.000_01'; # TRIAL |
3
|
|
|
|
|
|
|
$Bitcoin::Crypto::Role::ShallowClone::VERSION = '2.00001'; |
4
|
29
|
|
|
29
|
|
205122
|
use v5.10; |
|
29
|
|
|
|
|
127
|
|
5
|
29
|
|
|
29
|
|
227
|
use strict; |
|
29
|
|
|
|
|
72
|
|
|
29
|
|
|
|
|
685
|
|
6
|
29
|
|
|
29
|
|
188
|
use warnings; |
|
29
|
|
|
|
|
105
|
|
|
29
|
|
|
|
|
977
|
|
7
|
|
|
|
|
|
|
|
8
|
29
|
|
|
29
|
|
183
|
use Type::Params -sigs; |
|
29
|
|
|
|
|
84
|
|
|
29
|
|
|
|
|
303
|
|
9
|
29
|
|
|
29
|
|
16388
|
use Bitcoin::Crypto::Types qw(Object); |
|
29
|
|
|
|
|
102
|
|
|
29
|
|
|
|
|
233
|
|
10
|
29
|
|
|
29
|
|
97718
|
use Moo::Role; |
|
29
|
|
|
|
|
102
|
|
|
29
|
|
|
|
|
216
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
signature_for clone => ( |
13
|
|
|
|
|
|
|
method => Object, |
14
|
|
|
|
|
|
|
positional => [ |
15
|
|
|
|
|
|
|
], |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Clones up to two levels deep - main reference and any plain hash / array |
19
|
|
|
|
|
|
|
# references inside it |
20
|
|
|
|
|
|
|
sub clone |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
my ($self) = @_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %new_self; |
25
|
|
|
|
|
|
|
foreach my $key (keys %{$self}) { |
26
|
|
|
|
|
|
|
my $value = $self->{$key}; |
27
|
|
|
|
|
|
|
my $ref = ref $value; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
if ($ref eq 'ARRAY') { |
30
|
|
|
|
|
|
|
$new_self{$key} = [@{$value}]; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
elsif ($ref eq 'HASH') { |
33
|
|
|
|
|
|
|
$new_self{$key} = {%{$value}}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
|
|
|
|
|
|
$new_self{$key} = $value; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Don't use the constructor because not all state may be assignable this |
41
|
|
|
|
|
|
|
# way |
42
|
|
|
|
|
|
|
return bless \%new_self, ref $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|