| Filename | /home/doy/nytprof/kioku-new/accessor _native_type (defined at /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Attribute/Native/Trait.pm line 191) |
| Statements | Executed 41 statements in 521µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2 | 1 | 1 | 77µs | 77µs | Eval::Closure::__ANON__[accessor _native_type (defined at Moose/Meta/Attribute/Native/Trait.pm line 191):23] |
| 0 | 0 | 0 | 0s | 0s | Eval::Closure::__ANON__[accessor _native_type (defined at Moose/Meta/Attribute/Native/Trait.pm line 191):22] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # spent 77µs within Eval::Closure::__ANON__[accessor _native_type (defined at /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Attribute/Native/Trait.pm line 191):23] which was called 2 times, avg 39µs/call:
# 2 times (77µs+0s) by Eval::Closure::_clean_eval_closure at line 94 of Eval/Closure.pm, avg 39µs/call | ||||
| 2 | 38 | 427µs | my $attr = ${$_[0]}; | ||
| 3 | my $meta = ${$_[1]}; | ||||
| 4 | my $type_constraint = ${$_[2]}; | ||||
| 5 | my $type_constraint_obj = ${$_[3]}; | ||||
| 6 | #line 1 "accessor _native_type (defined at /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Attribute/Native/Trait.pm line 191)" | ||||
| 7 | 6 | 1.06ms | sub { # spent 1.03ms making 2 calls to Moose::Meta::Attribute::Native::Trait::_build_native_type, avg 517µs/call
# spent 15µs making 2 calls to UNIVERSAL::can, avg 7µs/call
# spent 14µs making 2 calls to Class::MOP::Mixin::AttributeCore::builder, avg 7µs/call | ||
| 8 | if (@_ > 1) { | ||||
| 9 | $meta->throw_error("Cannot assign a value to a read-only accessor", data => \@_); | ||||
| 10 | } | ||||
| 11 | if (!exists $_[0]->{"_native_type"}) { | ||||
| 12 | my $default; | ||||
| 13 | if (my $builder = $_[0]->can($attr->builder)) { | ||||
| 14 | $default = $_[0]->$builder; | ||||
| 15 | } | ||||
| 16 | 2 | 33µs | else { # spent 33µs making 2 calls to Moose::Util::TypeConstraints::OptimizedConstraints::Str, avg 17µs/call | ||
| 17 | my $class = ref($_[0]) || $_[0]; | ||||
| 18 | my $builder_name = $attr->builder; | ||||
| 19 | my $attr_name = $attr->name; | ||||
| 20 | $meta->throw_error("$class does not support builder method '$builder_name' for attribute '$attr_name'"); | ||||
| 21 | } | ||||
| 22 | if (!$type_constraint->($default)) { | ||||
| 23 | 2 | 67µs | $meta->throw_error("Attribute (_native_type) does not pass the type constraint because: " . $type_constraint_obj->get_message($default), data => $default); | ||
| 24 | 1 | 26µs | } | ||
| 25 | $_[0]->{"_native_type"} = $default; | ||||
| 26 | } | ||||
| 27 | return $_[0]->{"_native_type"}; | ||||
| 28 | } | ||||
| 29 | } | ||||
| 30 | ; |