Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Class/C3/Componentised.pm |
Statements | Executed 52761 statements in 180ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
24852 | 8 | 5 | 187ms | 454ms | ensure_class_loaded (recurses: max depth 3, inclusive time 76.2ms) | Class::C3::Componentised::
76 | 1 | 1 | 3.04ms | 3.04ms | __ANON__[:199] | Class::C3::Componentised::
42 | 1 | 1 | 2.45ms | 6.60ms | inject_base | Class::C3::Componentised::
41 | 41 | 41 | 1.29ms | 73.5ms | load_components (recurses: max depth 2, inclusive time 62.3ms) | Class::C3::Componentised::
42 | 2 | 1 | 998µs | 72.2ms | _load_components (recurses: max depth 3, inclusive time 72.2ms) | Class::C3::Componentised::
156 | 4 | 1 | 112µs | 112µs | CORE:match (opcode) | Class::C3::Componentised::
6 | 1 | 1 | 79µs | 2.00ms | load_optional_class | Class::C3::Componentised::
1 | 1 | 1 | 30µs | 10.1ms | load_own_components | Class::C3::Componentised::
1 | 1 | 1 | 12µs | 14µs | BEGIN@40 | Class::C3::Componentised::
1 | 1 | 1 | 8µs | 8µs | BEGIN@48 | Class::C3::Componentised::
1 | 1 | 1 | 8µs | 15µs | BEGIN@41 | Class::C3::Componentised::
1 | 1 | 1 | 7µs | 22µs | BEGIN@133 | Class::C3::Componentised::
1 | 1 | 1 | 7µs | 15µs | BEGIN@198 | Class::C3::Componentised::
1 | 1 | 1 | 4µs | 4µs | CORE:qr (opcode) | Class::C3::Componentised::
1 | 1 | 1 | 4µs | 4µs | BEGIN@50 | Class::C3::Componentised::
1 | 1 | 1 | 3µs | 3µs | BEGIN@51 | Class::C3::Componentised::
0 | 0 | 0 | 0s | 0s | __ANON__[:204] | Class::C3::Componentised::
0 | 0 | 0 | 0s | 0s | ensure_class_found | Class::C3::Componentised::
0 | 0 | 0 | 0s | 0s | load_optional_components | Class::C3::Componentised::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Class::C3::Componentised; | ||||
2 | |||||
3 | =head1 NAME | ||||
4 | |||||
5 | Class::C3::Componentised | ||||
6 | |||||
7 | =head1 DESCRIPTION | ||||
8 | |||||
9 | Load mix-ins or components to your C3-based class. | ||||
10 | |||||
11 | =head1 SYNOPSIS | ||||
12 | |||||
13 | package MyModule; | ||||
14 | |||||
15 | use strict; | ||||
16 | use warnings; | ||||
17 | |||||
18 | use base 'Class::C3::Componentised'; | ||||
19 | |||||
20 | sub component_base_class { "MyModule::Component" } | ||||
21 | |||||
22 | package main; | ||||
23 | |||||
24 | MyModule->load_components( qw/Foo Bar/ ); | ||||
25 | # Will load MyModule::Component::Foo and MyModule::Component::Bar | ||||
26 | |||||
27 | =head1 DESCRIPTION | ||||
28 | |||||
29 | This will inject base classes to your module using the L<Class::C3> method | ||||
30 | resolution order. | ||||
31 | |||||
32 | Please note: these are not plugins that can take precedence over methods | ||||
33 | declared in MyModule. If you want something like that, consider | ||||
34 | L<MooseX::Object::Pluggable>. | ||||
35 | |||||
36 | =head1 METHODS | ||||
37 | |||||
38 | =cut | ||||
39 | |||||
40 | 3 | 17µs | 2 | 16µs | # spent 14µs (12+2) within Class::C3::Componentised::BEGIN@40 which was called:
# once (12µs+2µs) by base::import at line 40 # spent 14µs making 1 call to Class::C3::Componentised::BEGIN@40
# spent 2µs making 1 call to strict::import |
41 | 3 | 18µs | 2 | 23µs | # spent 15µs (8+8) within Class::C3::Componentised::BEGIN@41 which was called:
# once (8µs+8µs) by base::import at line 41 # spent 15µs making 1 call to Class::C3::Componentised::BEGIN@41
# spent 8µs making 1 call to warnings::import |
42 | |||||
43 | # This will prime the Class::C3 namespace (either by loading it proper on 5.8 | ||||
44 | # or by installing compat shims on 5.10+). A user might have a reasonable | ||||
45 | # expectation that using Class::C3::<something> will give him access to | ||||
46 | # Class::C3 itself, and this module has been providing this historically. | ||||
47 | # Therefore leaving it in indefinitely. | ||||
48 | 3 | 20µs | 1 | 8µs | # spent 8µs within Class::C3::Componentised::BEGIN@48 which was called:
# once (8µs+0s) by base::import at line 48 # spent 8µs making 1 call to Class::C3::Componentised::BEGIN@48 |
49 | |||||
50 | 3 | 15µs | 1 | 4µs | # spent 4µs within Class::C3::Componentised::BEGIN@50 which was called:
# once (4µs+0s) by base::import at line 50 # spent 4µs making 1 call to Class::C3::Componentised::BEGIN@50 |
51 | 3 | 296µs | 1 | 3µs | # spent 3µs within Class::C3::Componentised::BEGIN@51 which was called:
# once (3µs+0s) by base::import at line 51 # spent 3µs making 1 call to Class::C3::Componentised::BEGIN@51 |
52 | |||||
53 | 1 | 700ns | our $VERSION = '1.001000'; | ||
54 | |||||
55 | 1 | 9µs | 1 | 4µs | $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases # spent 4µs making 1 call to Class::C3::Componentised::CORE:match |
56 | |||||
57 | 1 | 9µs | 1 | 4µs | my $invalid_class = qr/(?: \b:\b | \:{3,} | \:\:$ )/x; # spent 4µs making 1 call to Class::C3::Componentised::CORE:qr |
58 | |||||
59 | =head2 load_components( @comps ) | ||||
60 | |||||
61 | Loads the given components into the current module. If a module begins with a | ||||
62 | C<+> character, it is taken to be a fully qualified class name, otherwise | ||||
63 | C<< $class->component_base_class >> is prepended to it. | ||||
64 | |||||
65 | Calling this will call C<Class::C3::reinitialize>. | ||||
66 | |||||
67 | =cut | ||||
68 | |||||
69 | # spent 73.5ms (1.29+72.2) within Class::C3::Componentised::load_components which was called 41 times, avg 1.79ms/call:
# once (36µs+51.7ms) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 17 of Tapper/Schema/TestrunDB/Result/TestrunScheduling.pm
# once (26µs+6.95ms) by Tapper::Schema::TestTools::BEGIN@20 at line 29 of Tapper/Schema/TestrunDB.pm
# once (47µs+2.97ms) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/ReportsDB/Result/ReportFile.pm
# once (35µs+2.23ms) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/TestrunDB/Result/Queue.pm
# once (37µs+407µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/TestrunDB/Result/State.pm
# once (39µs+399µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/ReportsDB/Result/NotificationEvent.pm
# once (40µs+385µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/TestrunDB/Result/Message.pm
# once (40µs+385µs) by Class::C3::Componentised::ensure_class_loaded at line 17 of Tapper/Schema/ReportsDB/Result/Report.pm
# once (38µs+364µs) by Class::C3::Componentised::ensure_class_loaded at line 17 of Tapper/Schema/ReportsDB/Result/Tap.pm
# once (33µs+364µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/ReportsDB/Result/Contact.pm
# once (38µs+353µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/ReportsDB/Result/ReportComment.pm
# once (38µs+343µs) by Class::C3::Componentised::ensure_class_loaded at line 16 of Tapper/Schema/TestrunDB/Result/Testrun.pm
# once (31µs+339µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/ReportsDB/Result/Notification.pm
# once (32µs+315µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/TestrunDB/Result/HostFeature.pm
# once (33µs+309µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/TestrunDB/Result/Scenario.pm
# once (32µs+307µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/TestrunDB/Result/Host.pm
# once (33µs+304µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/TestrunDB/Result/ScenarioElement.pm
# once (31µs+302µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/TestrunDB/Result/TestplanInstance.pm
# once (27µs+246µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/ReportsDB/Result/Suite.pm
# once (31µs+222µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/TestrunDB/Result/TestrunRequestedHost.pm
# once (28µs+223µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/ReportsDB/Result/ReportgroupArbitrary.pm
# once (28µs+217µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/ReportsDB/Result/ReportSection.pm
# once (26µs+216µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/TestrunDB/Result/TestrunRequestedFeature.pm
# once (27µs+211µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/ReportsDB/Result/ReportgroupTestrunStats.pm
# once (27µs+210µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/ReportsDB/Result/ReportgroupTestrun.pm
# once (28µs+208µs) by Class::C3::Componentised::ensure_class_loaded at line 15 of Tapper/Schema/TestrunDB/Result/Precondition.pm
# once (25µs+208µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/ReportsDB/Result/ReportTopic.pm
# once (24µs+202µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/TestrunDB/Result/User.pm
# once (26µs+200µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/TestrunDB/Result/TestrunPrecondition.pm
# once (26µs+194µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/ReportsDB/Result/User.pm
# once (24µs+193µs) by Class::C3::Componentised::ensure_class_loaded at line 27 of Tapper/Schema/TestrunDB/Result/Preconditiontype.pm
# once (25µs+189µs) by Class::C3::Componentised::ensure_class_loaded at line 27 of Tapper/Schema/TestrunDB/Result/Topic.pm
# once (24µs+187µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/TestrunDB/Result/PrePrecondition.pm
# once (22µs+179µs) by Class::C3::Componentised::ensure_class_loaded at line 14 of Tapper/Schema/TestrunDB/Result/QueueHost.pm
# once (24µs+174µs) by Tapper::Schema::TestTools::BEGIN@21 at line 30 of Tapper/Schema/ReportsDB.pm
# once (27µs+171µs) by Class::C3::Componentised::ensure_class_loaded at line 9 of DBIx/Class/ResultSource/View.pm
# once (54µs+-54µs) by Class::C3::Componentised::ensure_class_loaded at line 8 of DBIx/Class/Core.pm
# once (28µs+-28µs) by DBIx::Class::ResultSourceProxy::Table::BEGIN@8 at line 9 of DBIx/Class/ResultSource/Table.pm
# once (24µs+-24µs) by Class::C3::Componentised::ensure_class_loaded at line 88 of DBIx/Class/InflateColumn/DateTime.pm
# once (41µs+-41µs) by Class::C3::Componentised::ensure_class_loaded at line 9 of DBIx/Class/Relationship/Helpers.pm
# once (28µs+-28µs) by Class::C3::Componentised::ensure_class_loaded at line 12 of DBIx/Class/TimeStamp.pm | ||||
70 | 232 | 1.41ms | my $class = shift; | ||
71 | 148 | 147µs | $class->_load_components( map { # spent 103µs making 73 calls to DBIx::Class::component_base_class, avg 1µs/call
# spent 44µs making 75 calls to Class::C3::Componentised::CORE:match, avg 588ns/call | ||
72 | 75 | 62µs | /^\+(.*)$/ # spent 62µs making 75 calls to Class::C3::Componentised::CORE:match, avg 823ns/call | ||
73 | ? $1 | ||||
74 | : join ('::', $class->component_base_class, $_) | ||||
75 | 41 | 72.2ms | } grep { $_ !~ /^#/ } @_ # spent 134ms making 41 calls to Class::C3::Componentised::_load_components, avg 3.28ms/call, recursion: max depth 3, sum of overlapping time 62.1ms | ||
76 | ); | ||||
77 | } | ||||
78 | |||||
79 | =head2 load_own_components( @comps ) | ||||
80 | |||||
81 | Similar to L<load_components>, but assumes every class is C<"$class::$comp">. | ||||
82 | |||||
83 | =cut | ||||
84 | |||||
85 | # spent 10.1ms (30µs+10.1) within Class::C3::Componentised::load_own_components which was called:
# once (30µs+10.1ms) by Class::C3::Componentised::ensure_class_loaded at line 8 of DBIx/Class/Relationship.pm | ||||
86 | 7 | 33µs | my $class = shift; | ||
87 | 6 | 3µs | $class->_load_components( map { "${class}::$_" } grep { $_ !~ /^#/ } @_ ); # spent 3µs making 5 calls to Class::C3::Componentised::CORE:match, avg 600ns/call
# spent 10.1ms making 1 call to Class::C3::Componentised::_load_components, recursion: max depth 2, sum of overlapping time 10.1ms | ||
88 | } | ||||
89 | |||||
90 | # spent 72.2ms (998µs+71.2) within Class::C3::Componentised::_load_components which was called 42 times, avg 1.72ms/call:
# 41 times (956µs+71.2ms) by Class::C3::Componentised::load_components at line 75, avg 1.76ms/call
# once (42µs+-42µs) by Class::C3::Componentised::load_own_components at line 87 | ||||
91 | 252 | 913µs | my $class = shift; | ||
92 | return unless @_; | ||||
93 | |||||
94 | 80 | 58.2ms | $class->ensure_class_loaded($_) for @_; # spent 133ms making 80 calls to Class::C3::Componentised::ensure_class_loaded, avg 1.67ms/call, recursion: max depth 3, sum of overlapping time 75.1ms | ||
95 | 42 | 10.0ms | $class->inject_base($class => @_); # spent 10.0ms making 42 calls to DBIx::Class::Componentised::inject_base, avg 239µs/call | ||
96 | 42 | 110µs | Class::C3::reinitialize(); # spent 110µs making 42 calls to MRO::Compat::__ANON__[MRO/Compat.pm:41], avg 3µs/call | ||
97 | } | ||||
98 | |||||
99 | =head2 load_optional_components | ||||
100 | |||||
101 | As L<load_components>, but will silently ignore any components that cannot be | ||||
102 | found. | ||||
103 | |||||
104 | =cut | ||||
105 | |||||
106 | sub load_optional_components { | ||||
107 | my $class = shift; | ||||
108 | $class->_load_components( grep | ||||
109 | { $class->load_optional_class( $_ ) } | ||||
110 | ( map | ||||
111 | { /^\+(.*)$/ | ||||
112 | ? $1 | ||||
113 | : join ('::', $class->component_base_class, $_) | ||||
114 | } | ||||
115 | grep { $_ !~ /^#/ } @_ | ||||
116 | ) | ||||
117 | ); | ||||
118 | } | ||||
119 | |||||
120 | =head2 ensure_class_loaded | ||||
121 | |||||
122 | Given a class name, tests to see if it is already loaded or otherwise | ||||
123 | defined. If it is not yet loaded, the package is require'd, and an exception | ||||
124 | is thrown if the class is still not loaded. | ||||
125 | |||||
126 | BUG: For some reason, packages with syntax errors are added to %INC on | ||||
127 | require | ||||
128 | =cut | ||||
129 | |||||
130 | # spent 454ms (187+267) within Class::C3::Componentised::ensure_class_loaded which was called 24852 times, avg 18µs/call:
# 24636 times (135ms+0s) by DBIx::Class::ResultSet::result_class at line 1387 of DBIx/Class/ResultSet.pm, avg 5µs/call
# 80 times (17.9ms+40.3ms) by Class::C3::Componentised::_load_components at line 94, avg 728µs/call
# 46 times (2.27ms+24.1ms) by DBIx::Class::AccessorGroup::get_component_class at line 16 of DBIx/Class/AccessorGroup.pm, avg 574µs/call
# 37 times (561µs+-552µs) by DBIx::Class::ResultSourceProxy::Table::table at line 87 of DBIx/Class/ResultSourceProxy/Table.pm, avg 265ns/call
# 35 times (18.7ms+96.6ms) by DBIx::Class::Schema::load_namespaces at line 246 of DBIx/Class/Schema.pm, avg 3.29ms/call
# 6 times (2.03ms+92.0ms) by DBIx::Class::Schema::load_namespaces at line 276 of DBIx/Class/Schema.pm, avg 15.7ms/call
# 6 times (9.27ms+13.1ms) by DBIx::Class::Schema::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Schema.pm:829] at line 828 of DBIx/Class/Schema.pm, avg 3.73ms/call
# 6 times (973µs+952µs) by Class::C3::Componentised::load_optional_class at line 227, avg 321µs/call | ||||
131 | 50515 | 170ms | my ($class, $f_class) = @_; | ||
132 | |||||
133 | 3 | 207µs | 2 | 38µs | # spent 22µs (7+15) within Class::C3::Componentised::BEGIN@133 which was called:
# once (7µs+15µs) by base::import at line 133 # spent 22µs making 1 call to Class::C3::Componentised::BEGIN@133
# spent 15µs making 1 call to strict::unimport |
134 | |||||
135 | # ripped from Class::Inspector for speed | ||||
136 | # note that the order is important (faster items are first) | ||||
137 | return if ${"${f_class}::VERSION"}; | ||||
138 | |||||
139 | return if @{"${f_class}::ISA"}; | ||||
140 | |||||
141 | my $file = (join ('/', split ('::', $f_class) ) ) . '.pm'; | ||||
142 | return if $INC{$file}; | ||||
143 | |||||
144 | for ( keys %{"${f_class}::"} ) { | ||||
145 | return if ( *{"${f_class}::$_"}{CODE} ); | ||||
146 | } | ||||
147 | |||||
148 | # require always returns true on success | ||||
149 | # ill-behaved modules might very well obliterate $_ | ||||
150 | eval { local $_; require($file) } or do { | ||||
151 | |||||
152 | $@ = "Invalid class name '$f_class'" if $f_class =~ $invalid_class; | ||||
153 | |||||
154 | if ($class->can('throw_exception')) { | ||||
155 | $class->throw_exception($@); | ||||
156 | } else { | ||||
157 | Carp::croak $@; | ||||
158 | } | ||||
159 | }; | ||||
160 | |||||
161 | return; | ||||
162 | } | ||||
163 | |||||
164 | =head2 ensure_class_found | ||||
165 | |||||
166 | Returns true if the specified class is installed or already loaded, false | ||||
167 | otherwise. | ||||
168 | |||||
169 | Note that the underlying mechanism (Class::Inspector->installed()) used by this | ||||
170 | sub will not, at the time of writing, correctly function when @INC includes | ||||
171 | coderefs. Since PAR relies upon coderefs in @INC, this function should be | ||||
172 | avoided in modules that are likely to be included within a PAR. | ||||
173 | |||||
174 | =cut | ||||
175 | |||||
176 | sub ensure_class_found { | ||||
177 | #my ($class, $f_class) = @_; | ||||
178 | require Class::Inspector; | ||||
179 | return Class::Inspector->loaded($_[1]) || | ||||
180 | Class::Inspector->installed($_[1]); | ||||
181 | } | ||||
182 | |||||
183 | |||||
184 | =head2 inject_base | ||||
185 | |||||
186 | Does the actual magic of adjusting @ISA on the target module. | ||||
187 | |||||
188 | =cut | ||||
189 | |||||
190 | # spent 6.60ms (2.45+4.15) within Class::C3::Componentised::inject_base which was called 42 times, avg 157µs/call:
# 42 times (2.45ms+4.15ms) by DBIx::Class::Componentised::inject_base at line 28 of mro.pm, avg 157µs/call | ||||
191 | 636 | 2.96ms | my $class = shift; | ||
192 | my $target = shift; | ||||
193 | |||||
194 | 42 | 121µs | mro::set_mro($target, 'c3'); # spent 121µs making 42 calls to mro::set_mro, avg 3µs/call | ||
195 | |||||
196 | for my $comp (reverse @_) { | ||||
197 | my $apply = do { | ||||
198 | 3 | 230µs | 2 | 24µs | # spent 15µs (7+8) within Class::C3::Componentised::BEGIN@198 which was called:
# once (7µs+8µs) by base::import at line 198 # spent 15µs making 1 call to Class::C3::Componentised::BEGIN@198
# spent 8µs making 1 call to strict::unimport |
199 | 76 | 3.16ms | # spent 3.04ms within Class::C3::Componentised::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Class/C3/Componentised.pm:199] which was called 76 times, avg 40µs/call:
# 76 times (3.04ms+0s) by Class::C3::Componentised::inject_base at line 208, avg 40µs/call | ||
200 | }; | ||||
201 | 80 | 335µs | unless ($target eq $comp || $target->isa($comp)) { # spent 335µs making 80 calls to UNIVERSAL::isa, avg 4µs/call | ||
202 | our %APPLICATOR_FOR; | ||||
203 | 152 | 653µs | if (my $apply_class # spent 527µs making 76 calls to List::Util::first, avg 7µs/call
# spent 126µs making 76 calls to mro::get_linear_isa, avg 2µs/call | ||
204 | 994 | 552µs | = List::Util::first { $APPLICATOR_FOR{$_} } @{mro::get_linear_isa($comp)} | ||
205 | ) { | ||||
206 | $APPLICATOR_FOR{$apply_class}->_apply_component_to_class($comp,$target,$apply); | ||||
207 | } else { | ||||
208 | 76 | 3.04ms | $apply->(); # spent 3.04ms making 76 calls to Class::C3::Componentised::__ANON__[Class/C3/Componentised.pm:199], avg 40µs/call | ||
209 | } | ||||
210 | } | ||||
211 | } | ||||
212 | } | ||||
213 | |||||
214 | =head2 load_optional_class | ||||
215 | |||||
216 | Returns a true value if the specified class is installed and loaded | ||||
217 | successfully, throws an exception if the class is found but not loaded | ||||
218 | successfully, and false if the class is not installed | ||||
219 | |||||
220 | =cut | ||||
221 | |||||
222 | # spent 2.00ms (79µs+1.92) within Class::C3::Componentised::load_optional_class which was called 6 times, avg 334µs/call:
# 6 times (79µs+1.92ms) by DBIx::Class::Storage::DBI::_determine_driver at line 1150 of DBIx/Class/Storage/DBI.pm, avg 334µs/call | ||||
223 | 24 | 73µs | my ($class, $f_class) = @_; | ||
224 | |||||
225 | # ensure_class_loaded either returns a () (*not* true) or throws | ||||
226 | eval { | ||||
227 | 6 | 1.92ms | $class->ensure_class_loaded($f_class); # spent 1.92ms making 6 calls to Class::C3::Componentised::ensure_class_loaded, avg 321µs/call | ||
228 | 1; | ||||
229 | } && return 1; | ||||
230 | |||||
231 | my $err = $@; # so we don't lose it | ||||
232 | |||||
233 | if ($f_class =~ $invalid_class) { | ||||
234 | $err = "Invalid class name '$f_class'"; | ||||
235 | } | ||||
236 | else { | ||||
237 | my $fn = quotemeta( (join ('/', split ('::', $f_class) ) ) . '.pm' ); | ||||
238 | return 0 if ($err =~ /Can't locate ${fn} in \@INC/ ); | ||||
239 | } | ||||
240 | |||||
241 | if ($class->can('throw_exception')) { | ||||
242 | $class->throw_exception($err); | ||||
243 | } | ||||
244 | else { | ||||
245 | die $err; | ||||
246 | } | ||||
247 | } | ||||
248 | |||||
249 | =head1 AUTHORS | ||||
250 | |||||
251 | Matt S. Trout and the L<DBIx::Class team|DBIx::Class/CONTRIBUTORS> | ||||
252 | |||||
253 | Pulled out into seperate module by Ash Berlin C<< <ash@cpan.org> >> | ||||
254 | |||||
255 | Optimizations and overall bolt-tightening by Peter "ribasushi" Rabbitson | ||||
256 | C<< <ribasushi@cpan.org> >> | ||||
257 | |||||
258 | =head1 COPYRIGHT | ||||
259 | |||||
260 | Copyright (c) 2006 - 2011 the Class::C3::Componentised L</AUTHORS> as listed | ||||
261 | above. | ||||
262 | |||||
263 | =head1 LICENSE | ||||
264 | |||||
265 | You may distribute this code under the same terms as Perl itself. | ||||
266 | |||||
267 | =cut | ||||
268 | |||||
269 | 1 | 5µs | 1; | ||
# spent 112µs within Class::C3::Componentised::CORE:match which was called 156 times, avg 720ns/call:
# 75 times (62µs+0s) by Class::C3::Componentised::load_components at line 72, avg 823ns/call
# 75 times (44µs+0s) by Class::C3::Componentised::load_components at line 71, avg 588ns/call
# 5 times (3µs+0s) by Class::C3::Componentised::load_own_components at line 87, avg 600ns/call
# once (4µs+0s) by base::import at line 55 | |||||
# spent 4µs within Class::C3::Componentised::CORE:qr which was called:
# once (4µs+0s) by base::import at line 57 |