File | /wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Chained/Fast.pm | Statements Executed | 13 | Total Time | 0.000305 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine | |
---|---|---|---|---|---|---|
3 | 1 | 1 | 3.2e-5 | 3.2e-5 | Class::Accessor::Chained::Fast:: | make_accessor |
0 | 0 | 0 | 0 | 0 | Class::Accessor::Chained::Fast:: | BEGIN |
0 | 0 | 0 | 0 | 0 | Class::Accessor::Chained::Fast:: | __ANON__[:15] |
0 | 0 | 0 | 0 | 0 | Class::Accessor::Chained::Fast:: | __ANON__[:34] |
0 | 0 | 0 | 0 | 0 | Class::Accessor::Chained::Fast:: | make_wo_accessor |
0 | 0 | 0 | 0 | 0 | base:: | BEGIN |
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | 3 | 3.8e-5 | 1.3e-5 | use strict; # spent 10µs making 1 call to strict::import |
2 | package Class::Accessor::Chained::Fast; | |||
3 | 3 | 0.00024 | 8.2e-5 | use base 'Class::Accessor::Fast'; # spent 3.34ms making 1 call to base::import, max recursion depth 2 |
4 | ||||
5 | # spent 32µs within Class::Accessor::Chained::Fast::make_accessor which was called 3 times, avg 11µs/call:
# 3 times (32µs+0) by Class::Accessor::_mk_accessors at line 166 of /wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor.pm, avg 11µs/call | |||
6 | 6 | 1.9e-5 | 3.2e-6 | my($class, $field) = @_; |
7 | ||||
8 | return sub { | |||
9 | my $self = shift; | |||
10 | if(@_) { | |||
11 | $self->{$field} = (@_ == 1 ? $_[0] : [@_]); | |||
12 | return $self; | |||
13 | } | |||
14 | return $self->{$field}; | |||
15 | }; | |||
16 | } | |||
17 | ||||
18 | sub make_wo_accessor { | |||
19 | my($class, $field) = @_; | |||
20 | ||||
21 | return sub { | |||
22 | my($self) = shift; | |||
23 | ||||
24 | unless (@_) { | |||
25 | my $caller = caller; | |||
26 | require Carp; | |||
27 | Carp::croak("'$caller' cannot access the value of '$field' on ". | |||
28 | "objects of class '$class'"); | |||
29 | } | |||
30 | else { | |||
31 | $self->{$field} = (@_ == 1 ? $_[0] : [@_]); | |||
32 | return $self; | |||
33 | } | |||
34 | }; | |||
35 | } | |||
36 | ||||
37 | 1 | 3.0e-6 | 3.0e-6 | 1; |
38 | ||||
39 | =head1 NAME | |||
40 | ||||
41 | Class::Accessor::Chained::Fast - Faster, but less expandable, chained accessors | |||
42 | ||||
43 | =head1 SYNOPSIS | |||
44 | ||||
45 | package Foo; | |||
46 | use base qw(Class::Accessor::Chained::Fast); | |||
47 | ||||
48 | # The rest as Class::Accessor::Chained except no set() or get(). | |||
49 | ||||
50 | =head1 DESCRIPTION | |||
51 | ||||
52 | By analogue to Class::Accessor and Class::Accessor::Fast this module | |||
53 | provides a faster less-flexible chained accessor maker. | |||
54 | ||||
55 | =head1 AUTHOR | |||
56 | ||||
57 | Richard Clamp <richardc@unixbeard.net> | |||
58 | ||||
59 | =head1 COPYRIGHT | |||
60 | ||||
61 | Copyright (C) 2003 Richard Clamp. All Rights Reserved. | |||
62 | ||||
63 | This module is free software; you can redistribute it and/or modify it | |||
64 | under the same terms as Perl itself. | |||
65 | ||||
66 | =head1 SEE ALSO | |||
67 | ||||
68 | L<Class::Accessor::Fast>, L<Class::Accessor::Chained> | |||
69 | ||||
70 | =cut |