line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Accessor::Faster; |
2
|
3
|
|
|
3
|
|
2024
|
use base 'Class::Accessor'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
255
|
|
3
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
61
|
|
4
|
3
|
|
|
3
|
|
11
|
use B 'perlstring'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
964
|
|
5
|
|
|
|
|
|
|
$Class::Accessor::Faster::VERSION = '0.51'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my %slot; |
8
|
|
|
|
|
|
|
sub _slot { |
9
|
26
|
|
|
26
|
|
43
|
my($class, $field) = @_; |
10
|
26
|
|
|
|
|
53
|
my $n = $slot{$class}->{$field}; |
11
|
26
|
100
|
|
|
|
51
|
return $n if defined $n; |
12
|
16
|
|
|
|
|
20
|
$n = keys %{$slot{$class}}; |
|
16
|
|
|
|
|
43
|
|
13
|
16
|
|
|
|
|
36
|
$slot{$class}->{$field} = $n; |
14
|
16
|
|
|
|
|
25
|
return $n; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
4
|
|
|
4
|
1
|
4253
|
my($proto, $fields) = @_; |
19
|
4
|
|
33
|
|
|
28
|
my($class) = ref $proto || $proto; |
20
|
4
|
|
|
|
|
13
|
my $self = bless [], $class; |
21
|
|
|
|
|
|
|
|
22
|
4
|
100
|
|
|
|
12
|
$fields = {} unless defined $fields; |
23
|
4
|
|
|
|
|
16
|
for my $k (keys %$fields) { |
24
|
8
|
|
|
|
|
20
|
my $n = $class->_slot($k); |
25
|
8
|
|
|
|
|
28
|
$self->[$n] = $fields->{$k}; |
26
|
|
|
|
|
|
|
} |
27
|
4
|
|
|
|
|
14
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub make_accessor { |
31
|
6
|
|
|
6
|
1
|
9
|
my($class, $field) = @_; |
32
|
6
|
|
|
|
|
13
|
my $n = $class->_slot($field); |
33
|
6
|
50
|
|
2
|
|
535
|
eval sprintf q{ |
|
2
|
0
|
|
2
|
|
532
|
|
|
0
|
100
|
|
|
|
0
|
|
|
2
|
50
|
|
|
|
8
|
|
|
1
|
100
|
|
|
|
4
|
|
|
6
|
100
|
|
|
|
1191
|
|
|
2
|
100
|
|
|
|
10
|
|
|
2
|
50
|
|
|
|
25
|
|
|
1
|
0
|
|
|
|
3
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
sub { |
35
|
|
|
|
|
|
|
return $_[0][%d] if scalar(@_) == 1; |
36
|
|
|
|
|
|
|
return $_[0][%d] = scalar(@_) == 2 ? $_[1] : [@_[1..$#_]]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
}, $n, $n; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub make_ro_accessor { |
42
|
6
|
|
|
6
|
1
|
12
|
my($class, $field) = @_; |
43
|
6
|
|
|
|
|
16
|
my $n = $class->_slot($field); |
44
|
6
|
100
|
|
4
|
|
560
|
eval sprintf q{ |
|
4
|
50
|
|
|
|
42
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
36
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
45
|
|
|
|
|
|
|
sub { |
46
|
|
|
|
|
|
|
return $_[0][%d] if @_ == 1; |
47
|
|
|
|
|
|
|
my $caller = caller; |
48
|
|
|
|
|
|
|
$_[0]->_croak(sprintf "'$caller' cannot alter the value of '%%s' on objects of class '%%s'", %s, %s); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
}, $n, map(perlstring($_), $field, $class); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub make_wo_accessor { |
54
|
6
|
|
|
6
|
1
|
14
|
my($class, $field) = @_; |
55
|
6
|
|
|
|
|
14
|
my $n = $class->_slot($field); |
56
|
6
|
100
|
|
3
|
|
889
|
eval sprintf q{ |
|
3
|
50
|
|
|
|
15
|
|
|
0
|
50
|
|
|
|
0
|
|
|
0
|
100
|
|
|
|
0
|
|
|
3
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
539
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
37
|
|
|
0
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub { |
58
|
|
|
|
|
|
|
if (@_ == 1) { |
59
|
|
|
|
|
|
|
my $caller = caller; |
60
|
|
|
|
|
|
|
$_[0]->_croak(sprintf "'$caller' cannot access the value of '%%s' on objects of class '%%s'", %s, %s); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else { |
63
|
|
|
|
|
|
|
return $_[0][%d] = $_[1] if @_ == 2; |
64
|
|
|
|
|
|
|
return (shift)->[%d] = \@_; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
}, map(perlstring($_), $field, $class), $n, $n; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |