Filename | /usr/share/perl/5.28/overloading.pm |
Statements | Executed 18 statements in 356µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3 | 3 | 2 | 20µs | 20µs | unimport | overloading::
1 | 1 | 1 | 10µs | 193µs | BEGIN@2 | overloading::
0 | 0 | 0 | 0s | 0s | _ops_to_nums | overloading::
0 | 0 | 0 | 0s | 0s | import | overloading::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package overloading; | ||||
2 | 2 | 312µs | 2 | 376µs | # spent 193µs (10+183) within overloading::BEGIN@2 which was called:
# once (10µs+183µs) by Carp::BEGIN@168 at line 2 # spent 193µs making 1 call to overloading::BEGIN@2
# spent 183µs making 1 call to warnings::import |
3 | |||||
4 | 1 | 300ns | our $VERSION = '0.02'; | ||
5 | |||||
6 | 1 | 200ns | my $HINT_NO_AMAGIC = 0x01000000; # see perl.h | ||
7 | |||||
8 | 1 | 11µs | require 5.010001; | ||
9 | |||||
10 | sub _ops_to_nums { | ||||
11 | require overload::numbers; | ||||
12 | |||||
13 | map { exists $overload::numbers::names{"($_"} | ||||
14 | ? $overload::numbers::names{"($_"} | ||||
15 | : do { require Carp; Carp::croak("'$_' is not a valid overload") } | ||||
16 | } @_; | ||||
17 | } | ||||
18 | |||||
19 | sub import { | ||||
20 | my ( $class, @ops ) = @_; | ||||
21 | |||||
22 | if ( @ops ) { | ||||
23 | if ( $^H{overloading} ) { | ||||
24 | vec($^H{overloading} , $_, 1) = 0 for _ops_to_nums(@ops); | ||||
25 | } | ||||
26 | |||||
27 | if ( $^H{overloading} !~ /[^\0]/ ) { | ||||
28 | delete $^H{overloading}; | ||||
29 | $^H &= ~$HINT_NO_AMAGIC; | ||||
30 | } | ||||
31 | } else { | ||||
32 | delete $^H{overloading}; | ||||
33 | $^H &= ~$HINT_NO_AMAGIC; | ||||
34 | } | ||||
35 | } | ||||
36 | |||||
37 | # spent 20µs within overloading::unimport which was called 3 times, avg 7µs/call:
# once (9µs+0s) by overload::BEGIN@81 at line 81 of overload.pm
# once (7µs+0s) by Carp::BEGIN@1 at line 1 of (eval 3)[Carp.pm:170]
# once (5µs+0s) by overload::BEGIN@112 at line 112 of overload.pm | ||||
38 | 3 | 2µs | my ( $class, @ops ) = @_; | ||
39 | |||||
40 | 3 | 6µs | if ( exists $^H{overloading} or not $^H & $HINT_NO_AMAGIC ) { | ||
41 | if ( @ops ) { | ||||
42 | vec($^H{overloading} ||= '', $_, 1) = 1 for _ops_to_nums(@ops); | ||||
43 | } else { | ||||
44 | 3 | 6µs | delete $^H{overloading}; | ||
45 | } | ||||
46 | } | ||||
47 | |||||
48 | 3 | 14µs | $^H |= $HINT_NO_AMAGIC; | ||
49 | } | ||||
50 | |||||
51 | 1 | 4µs | 1; | ||
52 | __END__ |