← Index
Performance Profile   « block view • line view • sub view »
For /wise/base/deliv/dev/bin/getfix
  Run on Thu May 20 15:30:03 2010
Reported on Thu May 20 16:25:36 2010

File/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Fast.pm
Statements Executed8
Total Time0.000329 seconds

Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
00000Class::Accessor::Fast::BEGIN
00000Class::Accessor::Fast::__ANON__[:41]
00000Class::Accessor::Fast::__ANON__[:52]
00000Class::Accessor::Fast::__ANON__[:68]
00000Class::Accessor::Fast::make_accessor
00000Class::Accessor::Fast::make_ro_accessor
00000Class::Accessor::Fast::make_wo_accessor

LineStmts.Exclusive
Time
Avg.Code
1package Class::Accessor::Fast;
233.0e-51.0e-5use base 'Class::Accessor';
# spent 2.29ms making 1 call to base::import, max recursion depth 3
330.000299.8e-5use strict;
# spent 8µs making 1 call to strict::import
411.0e-61.0e-6$Class::Accessor::Fast::VERSION = '0.31';
5
6=head1 NAME
7
8Class::Accessor::Fast - Faster, but less expandable, accessors
9
10=head1 SYNOPSIS
11
12 package Foo;
13 use base qw(Class::Accessor::Fast);
14
15 # The rest is the same as Class::Accessor but without set() and get().
16
17=head1 DESCRIPTION
18
19This is a faster but less expandable version of Class::Accessor.
20Class::Accessor's generated accessors require two method calls to accompish
21their task (one for the accessor, another for get() or set()).
22Class::Accessor::Fast eliminates calling set()/get() and does the access itself,
23resulting in a somewhat faster accessor.
24
25The downside is that you can't easily alter the behavior of your
26accessors, nor can your subclasses. Of course, should you need this
27later, you can always swap out Class::Accessor::Fast for
28Class::Accessor.
29
30Read the documentation for Class::Accessor for more info.
31
32=cut
33
34sub make_accessor {
35 my($class, $field) = @_;
36
37 return sub {
38 return $_[0]->{$field} if @_ == 1;
39 return $_[0]->{$field} = $_[1] if @_ == 2;
40 return (shift)->{$field} = \@_;
41 };
42}
43
44
45sub make_ro_accessor {
46 my($class, $field) = @_;
47
48 return sub {
49 return $_[0]->{$field} if @_ == 1;
50 my $caller = caller;
51 $_[0]->_croak("'$caller' cannot alter the value of '$field' on objects of class '$class'");
52 };
53}
54
55
56sub make_wo_accessor {
57 my($class, $field) = @_;
58
59 return sub {
60 if (@_ == 1) {
61 my $caller = caller;
62 $_[0]->_croak("'$caller' cannot access the value of '$field' on objects of class '$class'");
63 }
64 else {
65 return $_[0]->{$field} = $_[1] if @_ == 2;
66 return (shift)->{$field} = \@_;
67 }
68 };
69}
70
71
72=head1 EFFICIENCY
73
74L<Class::Accessor/EFFICIENCY> for an efficiency comparison.
75
76=head1 AUTHORS
77
78Copyright 2007 Marty Pauley <marty+perl@kasei.com>
79
80This program is free software; you can redistribute it and/or modify it under
81the same terms as Perl itself. That means either (a) the GNU General Public
82License or (b) the Artistic License.
83
84=head2 ORIGINAL AUTHOR
85
86Michael G Schwern <schwern@pobox.com>
87
88=head1 SEE ALSO
89
90L<Class::Accessor>
91
92=cut
93
9414.0e-64.0e-61;