File | /usr/local/lib/perl5/5.10.1/warnings.pm |
Statements Executed | 3000 |
Statement Execution Time | 3.30ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
205 | 142 | 138 | 2.27ms | 2.27ms | import | warnings::
28 | 28 | 16 | 429µs | 429µs | unimport | warnings::
1 | 1 | 2 | 16µs | 16µs | CORE:regcomp (opcode) | warnings::
1 | 1 | 2 | 4µs | 4µs | CORE:match (opcode) | warnings::
0 | 0 | 0 | 0s | 0s | Croaker | warnings::
0 | 0 | 0 | 0s | 0s | __chk | warnings::
0 | 0 | 0 | 0s | 0s | _error_loc | warnings::
0 | 0 | 0 | 0s | 0s | bits | warnings::
0 | 0 | 0 | 0s | 0s | enabled | warnings::
0 | 0 | 0 | 0s | 0s | warn | warnings::
0 | 0 | 0 | 0s | 0s | warnif | warnings::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # -*- buffer-read-only: t -*- | ||||
2 | # !!!!!!! DO NOT EDIT THIS FILE !!!!!!! | ||||
3 | # This file was created by warnings.pl | ||||
4 | # Any changes made here will be lost. | ||||
5 | # | ||||
6 | |||||
7 | package warnings; | ||||
8 | |||||
9 | 1 | 700ns | our $VERSION = '1.06'; | ||
10 | |||||
11 | # Verify that we're called correctly so that warnings will work. | ||||
12 | # see also strict.pm. | ||||
13 | 1 | 32µs | 2 | 20µs | unless ( __FILE__ =~ /(^|[\/\\])\Q${\__PACKAGE__}\E\.pmc?$/ ) { # spent 16µs making 1 call to warnings::CORE:regcomp
# spent 4µs making 1 call to warnings::CORE:match |
14 | my (undef, $f, $l) = caller; | ||||
15 | die("Incorrect use of pragma '${\__PACKAGE__}' at $f line $l.\n"); | ||||
16 | } | ||||
17 | |||||
18 | =head1 NAME | ||||
19 | |||||
20 | warnings - Perl pragma to control optional warnings | ||||
21 | |||||
22 | =head1 SYNOPSIS | ||||
23 | |||||
24 | use warnings; | ||||
25 | no warnings; | ||||
26 | |||||
27 | use warnings "all"; | ||||
28 | no warnings "all"; | ||||
29 | |||||
30 | use warnings::register; | ||||
31 | if (warnings::enabled()) { | ||||
32 | warnings::warn("some warning"); | ||||
33 | } | ||||
34 | |||||
35 | if (warnings::enabled("void")) { | ||||
36 | warnings::warn("void", "some warning"); | ||||
37 | } | ||||
38 | |||||
39 | if (warnings::enabled($object)) { | ||||
40 | warnings::warn($object, "some warning"); | ||||
41 | } | ||||
42 | |||||
43 | warnings::warnif("some warning"); | ||||
44 | warnings::warnif("void", "some warning"); | ||||
45 | warnings::warnif($object, "some warning"); | ||||
46 | |||||
47 | =head1 DESCRIPTION | ||||
48 | |||||
49 | The C<warnings> pragma is a replacement for the command line flag C<-w>, | ||||
50 | but the pragma is limited to the enclosing block, while the flag is global. | ||||
51 | See L<perllexwarn> for more information. | ||||
52 | |||||
53 | If no import list is supplied, all possible warnings are either enabled | ||||
54 | or disabled. | ||||
55 | |||||
56 | A number of functions are provided to assist module authors. | ||||
57 | |||||
58 | =over 4 | ||||
59 | |||||
60 | =item use warnings::register | ||||
61 | |||||
62 | Creates a new warnings category with the same name as the package where | ||||
63 | the call to the pragma is used. | ||||
64 | |||||
65 | =item warnings::enabled() | ||||
66 | |||||
67 | Use the warnings category with the same name as the current package. | ||||
68 | |||||
69 | Return TRUE if that warnings category is enabled in the calling module. | ||||
70 | Otherwise returns FALSE. | ||||
71 | |||||
72 | =item warnings::enabled($category) | ||||
73 | |||||
74 | Return TRUE if the warnings category, C<$category>, is enabled in the | ||||
75 | calling module. | ||||
76 | Otherwise returns FALSE. | ||||
77 | |||||
78 | =item warnings::enabled($object) | ||||
79 | |||||
80 | Use the name of the class for the object reference, C<$object>, as the | ||||
81 | warnings category. | ||||
82 | |||||
83 | Return TRUE if that warnings category is enabled in the first scope | ||||
84 | where the object is used. | ||||
85 | Otherwise returns FALSE. | ||||
86 | |||||
87 | =item warnings::warn($message) | ||||
88 | |||||
89 | Print C<$message> to STDERR. | ||||
90 | |||||
91 | Use the warnings category with the same name as the current package. | ||||
92 | |||||
93 | If that warnings category has been set to "FATAL" in the calling module | ||||
94 | then die. Otherwise return. | ||||
95 | |||||
96 | =item warnings::warn($category, $message) | ||||
97 | |||||
98 | Print C<$message> to STDERR. | ||||
99 | |||||
100 | If the warnings category, C<$category>, has been set to "FATAL" in the | ||||
101 | calling module then die. Otherwise return. | ||||
102 | |||||
103 | =item warnings::warn($object, $message) | ||||
104 | |||||
105 | Print C<$message> to STDERR. | ||||
106 | |||||
107 | Use the name of the class for the object reference, C<$object>, as the | ||||
108 | warnings category. | ||||
109 | |||||
110 | If that warnings category has been set to "FATAL" in the scope where C<$object> | ||||
111 | is first used then die. Otherwise return. | ||||
112 | |||||
113 | |||||
114 | =item warnings::warnif($message) | ||||
115 | |||||
116 | Equivalent to: | ||||
117 | |||||
118 | if (warnings::enabled()) | ||||
119 | { warnings::warn($message) } | ||||
120 | |||||
121 | =item warnings::warnif($category, $message) | ||||
122 | |||||
123 | Equivalent to: | ||||
124 | |||||
125 | if (warnings::enabled($category)) | ||||
126 | { warnings::warn($category, $message) } | ||||
127 | |||||
128 | =item warnings::warnif($object, $message) | ||||
129 | |||||
130 | Equivalent to: | ||||
131 | |||||
132 | if (warnings::enabled($object)) | ||||
133 | { warnings::warn($object, $message) } | ||||
134 | |||||
135 | =back | ||||
136 | |||||
137 | See L<perlmodlib/Pragmatic Modules> and L<perllexwarn>. | ||||
138 | |||||
139 | =cut | ||||
140 | |||||
141 | 1 | 23µs | our %Offsets = ( | ||
142 | |||||
143 | # Warnings Categories added in Perl 5.008 | ||||
144 | |||||
145 | 'all' => 0, | ||||
146 | 'closure' => 2, | ||||
147 | 'deprecated' => 4, | ||||
148 | 'exiting' => 6, | ||||
149 | 'glob' => 8, | ||||
150 | 'io' => 10, | ||||
151 | 'closed' => 12, | ||||
152 | 'exec' => 14, | ||||
153 | 'layer' => 16, | ||||
154 | 'newline' => 18, | ||||
155 | 'pipe' => 20, | ||||
156 | 'unopened' => 22, | ||||
157 | 'misc' => 24, | ||||
158 | 'numeric' => 26, | ||||
159 | 'once' => 28, | ||||
160 | 'overflow' => 30, | ||||
161 | 'pack' => 32, | ||||
162 | 'portable' => 34, | ||||
163 | 'recursion' => 36, | ||||
164 | 'redefine' => 38, | ||||
165 | 'regexp' => 40, | ||||
166 | 'severe' => 42, | ||||
167 | 'debugging' => 44, | ||||
168 | 'inplace' => 46, | ||||
169 | 'internal' => 48, | ||||
170 | 'malloc' => 50, | ||||
171 | 'signal' => 52, | ||||
172 | 'substr' => 54, | ||||
173 | 'syntax' => 56, | ||||
174 | 'ambiguous' => 58, | ||||
175 | 'bareword' => 60, | ||||
176 | 'digit' => 62, | ||||
177 | 'parenthesis' => 64, | ||||
178 | 'precedence' => 66, | ||||
179 | 'printf' => 68, | ||||
180 | 'prototype' => 70, | ||||
181 | 'qw' => 72, | ||||
182 | 'reserved' => 74, | ||||
183 | 'semicolon' => 76, | ||||
184 | 'taint' => 78, | ||||
185 | 'threads' => 80, | ||||
186 | 'uninitialized' => 82, | ||||
187 | 'unpack' => 84, | ||||
188 | 'untie' => 86, | ||||
189 | 'utf8' => 88, | ||||
190 | 'void' => 90, | ||||
191 | ); | ||||
192 | |||||
193 | 1 | 19µs | our %Bits = ( | ||
194 | 'all' => "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x05", # [0..45] | ||||
195 | 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00", # [29] | ||||
196 | 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00", # [30] | ||||
197 | 'closed' => "\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6] | ||||
198 | 'closure' => "\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1] | ||||
199 | 'debugging' => "\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00", # [22] | ||||
200 | 'deprecated' => "\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [2] | ||||
201 | 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00", # [31] | ||||
202 | 'exec' => "\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] | ||||
203 | 'exiting' => "\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] | ||||
204 | 'glob' => "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4] | ||||
205 | 'inplace' => "\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00", # [23] | ||||
206 | 'internal' => "\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00", # [24] | ||||
207 | 'io' => "\x00\x54\x55\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [5..11] | ||||
208 | 'layer' => "\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8] | ||||
209 | 'malloc' => "\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00", # [25] | ||||
210 | 'misc' => "\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00", # [12] | ||||
211 | 'newline' => "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9] | ||||
212 | 'numeric' => "\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00", # [13] | ||||
213 | 'once' => "\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00", # [14] | ||||
214 | 'overflow' => "\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00", # [15] | ||||
215 | 'pack' => "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00", # [16] | ||||
216 | 'parenthesis' => "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00", # [32] | ||||
217 | 'pipe' => "\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [10] | ||||
218 | 'portable' => "\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00", # [17] | ||||
219 | 'precedence' => "\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00", # [33] | ||||
220 | 'printf' => "\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00", # [34] | ||||
221 | 'prototype' => "\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00", # [35] | ||||
222 | 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00", # [36] | ||||
223 | 'recursion' => "\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00", # [18] | ||||
224 | 'redefine' => "\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00", # [19] | ||||
225 | 'regexp' => "\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00", # [20] | ||||
226 | 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00", # [37] | ||||
227 | 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00", # [38] | ||||
228 | 'severe' => "\x00\x00\x00\x00\x00\x54\x05\x00\x00\x00\x00\x00", # [21..25] | ||||
229 | 'signal' => "\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00", # [26] | ||||
230 | 'substr' => "\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00", # [27] | ||||
231 | 'syntax' => "\x00\x00\x00\x00\x00\x00\x00\x55\x55\x15\x00\x00", # [28..38] | ||||
232 | 'taint' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00", # [39] | ||||
233 | 'threads' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00", # [40] | ||||
234 | 'uninitialized' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00", # [41] | ||||
235 | 'unopened' => "\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [11] | ||||
236 | 'unpack' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00", # [42] | ||||
237 | 'untie' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00", # [43] | ||||
238 | 'utf8' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", # [44] | ||||
239 | 'void' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04", # [45] | ||||
240 | ); | ||||
241 | |||||
242 | 1 | 16µs | our %DeadBits = ( | ||
243 | 'all' => "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\x0a", # [0..45] | ||||
244 | 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00", # [29] | ||||
245 | 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00", # [30] | ||||
246 | 'closed' => "\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6] | ||||
247 | 'closure' => "\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1] | ||||
248 | 'debugging' => "\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00", # [22] | ||||
249 | 'deprecated' => "\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [2] | ||||
250 | 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00", # [31] | ||||
251 | 'exec' => "\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] | ||||
252 | 'exiting' => "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] | ||||
253 | 'glob' => "\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4] | ||||
254 | 'inplace' => "\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00", # [23] | ||||
255 | 'internal' => "\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00", # [24] | ||||
256 | 'io' => "\x00\xa8\xaa\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [5..11] | ||||
257 | 'layer' => "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8] | ||||
258 | 'malloc' => "\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00", # [25] | ||||
259 | 'misc' => "\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00", # [12] | ||||
260 | 'newline' => "\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9] | ||||
261 | 'numeric' => "\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00", # [13] | ||||
262 | 'once' => "\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00", # [14] | ||||
263 | 'overflow' => "\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00", # [15] | ||||
264 | 'pack' => "\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00", # [16] | ||||
265 | 'parenthesis' => "\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00", # [32] | ||||
266 | 'pipe' => "\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [10] | ||||
267 | 'portable' => "\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00", # [17] | ||||
268 | 'precedence' => "\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00", # [33] | ||||
269 | 'printf' => "\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00", # [34] | ||||
270 | 'prototype' => "\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00", # [35] | ||||
271 | 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00", # [36] | ||||
272 | 'recursion' => "\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00", # [18] | ||||
273 | 'redefine' => "\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00", # [19] | ||||
274 | 'regexp' => "\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00", # [20] | ||||
275 | 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00", # [37] | ||||
276 | 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00", # [38] | ||||
277 | 'severe' => "\x00\x00\x00\x00\x00\xa8\x0a\x00\x00\x00\x00\x00", # [21..25] | ||||
278 | 'signal' => "\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00", # [26] | ||||
279 | 'substr' => "\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00", # [27] | ||||
280 | 'syntax' => "\x00\x00\x00\x00\x00\x00\x00\xaa\xaa\x2a\x00\x00", # [28..38] | ||||
281 | 'taint' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00", # [39] | ||||
282 | 'threads' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00", # [40] | ||||
283 | 'uninitialized' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00", # [41] | ||||
284 | 'unopened' => "\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [11] | ||||
285 | 'unpack' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00", # [42] | ||||
286 | 'untie' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00", # [43] | ||||
287 | 'utf8' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02", # [44] | ||||
288 | 'void' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08", # [45] | ||||
289 | ); | ||||
290 | |||||
291 | 1 | 300ns | $NONE = "\0\0\0\0\0\0\0\0\0\0\0\0"; | ||
292 | 1 | 100ns | $LAST_BIT = 92 ; | ||
293 | 1 | 100ns | $BYTES = 12 ; | ||
294 | |||||
295 | 2 | 11µs | $All = "" ; vec($All, $Offsets{'all'}, 2) = 3 ; | ||
296 | |||||
297 | sub Croaker | ||||
298 | { | ||||
299 | require Carp::Heavy; # this initializes %CarpInternal | ||||
300 | local $Carp::CarpInternal{'warnings'}; | ||||
301 | delete $Carp::CarpInternal{'warnings'}; | ||||
302 | Carp::croak(@_); | ||||
303 | } | ||||
304 | |||||
305 | sub bits | ||||
306 | { | ||||
307 | # called from B::Deparse.pm | ||||
308 | |||||
309 | push @_, 'all' unless @_; | ||||
310 | |||||
311 | my $mask; | ||||
312 | my $catmask ; | ||||
313 | my $fatal = 0 ; | ||||
314 | my $no_fatal = 0 ; | ||||
315 | |||||
316 | foreach my $word ( @_ ) { | ||||
317 | if ($word eq 'FATAL') { | ||||
318 | $fatal = 1; | ||||
319 | $no_fatal = 0; | ||||
320 | } | ||||
321 | elsif ($word eq 'NONFATAL') { | ||||
322 | $fatal = 0; | ||||
323 | $no_fatal = 1; | ||||
324 | } | ||||
325 | elsif ($catmask = $Bits{$word}) { | ||||
326 | $mask |= $catmask ; | ||||
327 | $mask |= $DeadBits{$word} if $fatal ; | ||||
328 | $mask &= ~($DeadBits{$word}|$All) if $no_fatal ; | ||||
329 | } | ||||
330 | else | ||||
331 | { Croaker("Unknown warnings category '$word'")} | ||||
332 | } | ||||
333 | |||||
334 | return $mask ; | ||||
335 | } | ||||
336 | |||||
337 | sub import | ||||
338 | # spent 2.27ms within warnings::import which was called 205 times, avg 11µs/call:
# 59 times (640µs+0s) by Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:389] at line 345 of Moose/Exporter.pm, avg 11µs/call
# 5 times (50µs+0s) by Moose::Exporter::import at line 567 of Moose/Exporter.pm, avg 10µs/call
# 2 times (18µs+0s) by MooseX::Types::import at line 336 of MooseX/Types.pm, avg 9µs/call
# once (24µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/Ignore.pm
# once (24µs+0s) by utf8::BEGIN@3 at line 3 of utf8_heavy.pl
# once (23µs+0s) by Compress::Raw::Zlib::BEGIN@12 at line 12 of Compress/Raw/Zlib.pm
# once (23µs+0s) by Test::More::BEGIN@5 at line 5 of Test/More.pm
# once (22µs+0s) by Class::MOP::Mixin::AttributeCore::BEGIN@4 at line 4 of Class/MOP/Mixin/AttributeCore.pm
# once (21µs+0s) by DateTime::BEGIN@6 at line 6 of DateTime.pm
# once (21µs+0s) by IO::Uncompress::Gunzip::BEGIN@9 at line 9 of IO/Uncompress/Gunzip.pm
# once (20µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/Hash.pm
# once (20µs+0s) by Class::MOP::Mixin::BEGIN@4 at line 4 of Class/MOP/Mixin.pm
# once (20µs+0s) by DateTime::TimeZone::BEGIN@6 at line 6 of DateTime/TimeZone.pm
# once (20µs+0s) by File::Basename::BEGIN@52 at line 52 of File/Basename.pm
# once (20µs+0s) by Module::Find::BEGIN@5 at line 5 of Module/Find.pm
# once (19µs+0s) by MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@4 at line 4 of MooseX/ClassAttribute/Role/Meta/Attribute.pm
# once (19µs+0s) by Moose::Meta::Mixin::AttributeCore::BEGIN@4 at line 4 of Moose/Meta/Mixin/AttributeCore.pm
# once (18µs+0s) by MooseX::Types::UndefinedType::BEGIN@9 at line 9 of MooseX/Types/UndefinedType.pm
# once (17µs+0s) by Class::MOP::Deprecated::BEGIN@4 at line 4 of Class/MOP/Deprecated.pm
# once (16µs+0s) by DateTime::Infinite::BEGIN@4 at line 4 of DateTime/Infinite.pm
# once (16µs+0s) by IO::Compress::Base::Common::BEGIN@4 at line 4 of IO/Compress/Base/Common.pm
# once (16µs+0s) by Class::MOP::Class::BEGIN@5 at line 5 of Class/MOP/Class.pm
# once (15µs+0s) by Moose::BEGIN@3 at line 3 of Moose.pm
# once (15µs+0s) by Devel::StackTraceFrame::BEGIN@245 at line 245 of Devel/StackTrace.pm
# once (15µs+0s) by Params::Validate::BEGIN@4 at line 4 of Params/ValidateXS.pm
# once (14µs+0s) by IO::Compress::Gzip::Constants::BEGIN@4 at line 4 of IO/Compress/Gzip/Constants.pm
# once (14µs+0s) by main::BEGIN@2 at line 2 of Test/Deep.pm
# once (14µs+0s) by IO::Compress::Zlib::Extra::BEGIN@6 at line 6 of IO/Compress/Zlib/Extra.pm
# once (13µs+0s) by Class::MOP::Module::BEGIN@5 at line 5 of Class/MOP/Module.pm
# once (13µs+0s) by Test::Deep::Ignore::BEGIN@2 at line 2 of Test/Deep/Cmp.pm
# once (13µs+0s) by Moose::Util::MetaRole::BEGIN@4 at line 4 of Moose/Util/MetaRole.pm
# once (13µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/ArrayLength.pm
# once (13µs+0s) by IO::Uncompress::Adapter::Inflate::BEGIN@4 at line 4 of IO/Uncompress/Adapter/Inflate.pm
# once (13µs+0s) by Moose::Meta::Role::Composite::BEGIN@4 at line 4 of Moose/Meta/Role/Composite.pm
# once (13µs+0s) by IO::BEGIN@8 at line 8 of IO.pm
# once (12µs+0s) by Class::MOP::Object::BEGIN@5 at line 5 of Class/MOP/Object.pm
# once (12µs+0s) by IO::Uncompress::RawInflate::BEGIN@5 at line 5 of IO/Uncompress/RawInflate.pm
# once (12µs+0s) by Test::Deep::Hash::BEGIN@2 at line 2 of Test/Deep/HashKeys.pm
# once (12µs+0s) by Moose::Meta::Instance::BEGIN@5 at line 5 of Moose/Meta/Instance.pm
# once (12µs+0s) by MooseX::Types::Util::BEGIN@9 at line 9 of MooseX/Types/Util.pm
# once (12µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/Shallow.pm
# once (12µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/RefType.pm
# once (12µs+0s) by Memcached::libmemcached::BEGIN@3 at line 3 of Memcached/libmemcached.pm
# once (12µs+0s) by Test::Deep::HashKeys::BEGIN@2 at line 2 of Test/Deep/HashKeysOnly.pm
# once (12µs+0s) by IO::Compress::Base::Common::BEGIN@502 at line 502 of IO/Compress/Base/Common.pm
# once (11µs+0s) by Test::Deep::Hash::BEGIN@2 at line 2 of Test/Deep/Ref.pm
# once (11µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/Blessed.pm
# once (11µs+0s) by Test::Deep::Hash::BEGIN@2 at line 2 of Test/Deep/HashElements.pm
# once (11µs+0s) by Moose::Role::BEGIN@3 at line 3 of Moose/Role.pm
# once (11µs+0s) by DateTime::Locale::Catalog::BEGIN@18 at line 18 of DateTime/Locale/Catalog.pm
# once (11µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/ArrayElementsOnly.pm
# once (10µs+0s) by Test::Builder::BEGIN@5 at line 5 of Test/Builder.pm
# once (10µs+0s) by Sub::Install::BEGIN@3 at line 3 of Sub/Install.pm
# once (10µs+0s) by UUID::Tiny::BEGIN@4 at line 4 of UUID/Tiny.pm
# once (10µs+0s) by Class::MOP::Method::Constructor::BEGIN@5 at line 5 of Class/MOP/Method/Constructor.pm
# once (10µs+0s) by IO::Uncompress::Base::BEGIN@5 at line 5 of IO/Uncompress/Base.pm
# once (10µs+0s) by Class::MOP::Mixin::HasMethods::BEGIN@4 at line 4 of Class/MOP/Mixin/HasMethods.pm
# once (10µs+0s) by SimpleDB::Class::Types::BEGIN@70 at line 70 of ../lib/SimpleDB/Class/Types.pm
# once (10µs+0s) by Moose::Meta::Role::Method::Conflicting::BEGIN@5 at line 5 of Moose/Meta/Role/Method/Conflicting.pm
# once (10µs+0s) by Class::MOP::Method::Accessor::BEGIN@5 at line 5 of Class/MOP/Method/Accessor.pm
# once (10µs+0s) by Moose::Meta::TypeConstraint::BEGIN@5 at line 5 of Moose/Meta/TypeConstraint.pm
# once (10µs+0s) by MooseX::ClassAttribute::BEGIN@4 at line 4 of MooseX/ClassAttribute.pm
# once (10µs+0s) by namespace::clean::BEGIN@9 at line 9 of namespace/clean.pm
# once (10µs+0s) by Class::MOP::Mixin::HasAttributes::BEGIN@4 at line 4 of Class/MOP/Mixin/HasAttributes.pm
# once (10µs+0s) by MooseX::Types::Moose::BEGIN@9 at line 9 of MooseX/Types/Moose.pm
# once (10µs+0s) by Moose::Meta::Role::BEGIN@5 at line 5 of Moose/Meta/Role.pm
# once (10µs+0s) by Moose::Meta::Attribute::BEGIN@5 at line 5 of Moose/Meta/Attribute.pm
# once (9µs+0s) by Class::MOP::Method::Inlined::BEGIN@4 at line 4 of Class/MOP/Method/Inlined.pm
# once (9µs+0s) by Class::MOP::Attribute::BEGIN@5 at line 5 of Class/MOP/Attribute.pm
# once (9µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/Array.pm
# once (9µs+0s) by Moose::Meta::Method::Destructor::BEGIN@5 at line 5 of Moose/Meta/Method/Destructor.pm
# once (9µs+0s) by Moose::Meta::Role::Application::ToRole::BEGIN@4 at line 4 of Moose/Meta/Role/Application/ToRole.pm
# once (9µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/ArrayLengthOnly.pm
# once (9µs+0s) by Moose::Meta::Role::Method::BEGIN@5 at line 5 of Moose/Meta/Role/Method.pm
# once (9µs+0s) by Sub::Name::BEGIN@45 at line 45 of Sub/Name.pm
# once (9µs+0s) by Moose::Meta::Method::Accessor::BEGIN@5 at line 5 of Moose/Meta/Method/Accessor.pm
# once (9µs+0s) by DateTime::Locale::BEGIN@4 at line 4 of DateTime/Locale.pm
# once (9µs+0s) by re::BEGIN@5 at line 5 of re.pm
# once (9µs+0s) by Moose::Meta::Role::Application::ToInstance::BEGIN@4 at line 4 of Moose/Meta/Role/Application/ToInstance.pm
# once (9µs+0s) by Exception::Class::Base::BEGIN@4 at line 4 of Exception/Class/Base.pm
# once (9µs+0s) by DateTime::TimeZone::Local::BEGIN@4 at line 4 of DateTime/TimeZone/Local.pm
# once (9µs+0s) by Devel::GlobalDestruction::BEGIN@6 at line 6 of Devel/GlobalDestruction.pm
# once (9µs+0s) by DateTime::Locale::en_US::BEGIN@22 at line 22 of DateTime/Locale/en_US.pm
# once (9µs+0s) by Moose::Util::BEGIN@4 at line 4 of Moose/Util.pm
# once (9µs+0s) by MooseX::ClassAttribute::Role::Meta::Class::BEGIN@4 at line 4 of MooseX/ClassAttribute/Role/Meta/Class.pm
# once (9µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@4 at line 4 of Moose/Meta/TypeConstraint/Parameterized.pm
# once (9µs+0s) by Moose::Error::Default::BEGIN@4 at line 4 of Moose/Error/Default.pm
# once (9µs+0s) by Moose::Meta::TypeConstraint::Registry::BEGIN@5 at line 5 of Moose/Meta/TypeConstraint/Registry.pm
# once (9µs+0s) by Class::MOP::Method::Wrapped::BEGIN@5 at line 5 of Class/MOP/Method/Wrapped.pm
# once (9µs+0s) by Moose::Meta::Class::Immutable::Trait::BEGIN@4 at line 4 of Moose/Meta/Class/Immutable/Trait.pm
# once (9µs+0s) by Devel::GlobalDestruction::BEGIN@3 at line 3 of Sub/Exporter.pm
# once (9µs+0s) by Moose::Meta::Method::Delegation::BEGIN@5 at line 5 of Moose/Meta/Method/Delegation.pm
# once (9µs+0s) by DateTime::Duration::BEGIN@4 at line 4 of DateTime/Duration.pm
# once (9µs+0s) by Moose::Meta::TypeConstraint::Role::BEGIN@4 at line 4 of Moose/Meta/TypeConstraint/Role.pm
# once (9µs+0s) by Devel::StackTrace::BEGIN@6 at line 6 of Devel/StackTrace.pm
# once (9µs+0s) by POSIX::BEGIN@3 at line 3 of POSIX.pm
# once (9µs+0s) by Moose::Meta::TypeConstraint::Enum::BEGIN@4 at line 4 of Moose/Meta/TypeConstraint/Enum.pm
# once (9µs+0s) by MooseX::Types::CheckedUtilExports::BEGIN@11 at line 11 of MooseX/Types/CheckedUtilExports.pm
# once (9µs+0s) by Moose::Meta::TypeCoercion::BEGIN@5 at line 5 of Moose/Meta/TypeCoercion.pm
# once (9µs+0s) by Moose::Meta::TypeConstraint::DuckType::BEGIN@4 at line 4 of Moose/Meta/TypeConstraint/DuckType.pm
# once (9µs+0s) by Moose::Meta::Role::Application::BEGIN@4 at line 4 of Moose/Meta/Role/Application.pm
# once (9µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/Stack.pm
# once (9µs+0s) by Moose::Meta::Role::Application::ToClass::BEGIN@4 at line 4 of Moose/Meta/Role/Application/ToClass.pm
# once (9µs+0s) by Moose::Meta::Role::Application::RoleSummation::BEGIN@4 at line 4 of Moose/Meta/Role/Application/RoleSummation.pm
# once (9µs+0s) by Class::MOP::Class::Immutable::Trait::BEGIN@4 at line 4 of Class/MOP/Class/Immutable/Trait.pm
# once (9µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/Cache.pm
# once (9µs+0s) by Test::Deep::BEGIN@2 at line 2 of Test/Deep/RegexpVersion.pm
# once (9µs+0s) by Moose::Meta::Method::Constructor::BEGIN@5 at line 5 of Moose/Meta/Method/Constructor.pm
# once (9µs+0s) by Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 at line 4 of Moose/Meta/TypeConstraint/Parameterizable.pm
# once (9µs+0s) by Moose::Meta::Method::Augmented::BEGIN@4 at line 4 of Moose/Meta/Method/Augmented.pm
# once (9µs+0s) by MooseX::Types::TypeDecorator::BEGIN@4 at line 4 of MooseX/Types/TypeDecorator.pm
# once (9µs+0s) by Moose::Meta::Role::Attribute::BEGIN@4 at line 4 of Moose/Meta/Role/Attribute.pm
# once (9µs+0s) by Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@4 at line 4 of Moose/Util/TypeConstraints/OptimizedConstraints.pm
# once (9µs+0s) by Moose::Meta::Method::Overridden::BEGIN@4 at line 4 of Moose/Meta/Method/Overridden.pm
# once (9µs+0s) by Moose::Meta::Role::Method::Required::BEGIN@5 at line 5 of Moose/Meta/Role/Method/Required.pm
# once (9µs+0s) by Class::MOP::Method::Generated::BEGIN@5 at line 5 of Class/MOP/Method/Generated.pm
# once (9µs+0s) by Moose::Meta::TypeConstraint::Class::BEGIN@4 at line 4 of Moose/Meta/TypeConstraint/Class.pm
# once (9µs+0s) by Moose::Exporter::BEGIN@4 at line 4 of Moose/Exporter.pm
# once (9µs+0s) by Moose::Object::BEGIN@5 at line 5 of Moose/Object.pm
# once (9µs+0s) by Moose::Meta::Class::BEGIN@5 at line 5 of Moose/Meta/Class.pm
# once (9µs+0s) by Class::MOP::Package::BEGIN@5 at line 5 of Class/MOP/Package.pm
# once (9µs+0s) by DateTime::Locale::root::BEGIN@22 at line 22 of DateTime/Locale/root.pm
# once (9µs+0s) by DateTime::Locale::en::BEGIN@22 at line 22 of DateTime/Locale/en.pm
# once (9µs+0s) by namespace::clean::BEGIN@2 at line 2 of B/Hooks/EndOfScope.pm
# once (8µs+0s) by Test::Deep::Cache::BEGIN@2 at line 2 of Test/Deep/Cache/Simple.pm
# once (8µs+0s) by Moose::Meta::Method::BEGIN@4 at line 4 of Moose/Meta/Method.pm
# once (8µs+0s) by Moose::Meta::TypeConstraint::Union::BEGIN@5 at line 5 of Moose/Meta/TypeConstraint/Union.pm
# once (8µs+0s) by File::GlobMapper::BEGIN@4 at line 4 of File/GlobMapper.pm
# once (8µs+0s) by Class::MOP::Method::BEGIN@5 at line 5 of Class/MOP/Method.pm
# once (8µs+0s) by Moose::Meta::TypeCoercion::Union::BEGIN@5 at line 5 of Moose/Meta/TypeCoercion/Union.pm
# once (8µs+0s) by DateTime::Helpers::BEGIN@4 at line 4 of DateTime/Helpers.pm
# once (8µs+0s) by MRO::Compat::BEGIN@3 at line 3 of MRO/Compat.pm
# once (8µs+0s) by File::Find::BEGIN@4 at line 4 of File/Find.pm
# once (8µs+0s) by metaclass::BEGIN@5 at line 5 of metaclass.pm
# once (8µs+0s) by DateTime::Locale::Base::BEGIN@4 at line 4 of DateTime/Locale/Base.pm
# once (8µs+0s) by Variable::Magic::BEGIN@6 at line 6 of Variable/Magic.pm
# once (8µs+0s) by mro::BEGIN@11 at line 11 of mro.pm
# once (8µs+0s) by Data::OptList::BEGIN@4 at line 4 of Data/OptList.pm
# once (8µs+0s) by Class::MOP::BEGIN@5 at line 5 of Class/MOP.pm
# once (8µs+0s) by Test::Deep::Stack::BEGIN@2 at line 2 of Test/Deep/MM.pm
# once (8µs+0s) by MooseX::ClassAttribute::Meta::Method::Accessor::BEGIN@4 at line 4 of MooseX/ClassAttribute/Meta/Method/Accessor.pm
# once (8µs+0s) by Class::MOP::Instance::BEGIN@5 at line 5 of Class/MOP/Instance.pm | ||||
339 | 2709 | 2.60ms | shift; | ||
340 | |||||
341 | my $catmask ; | ||||
342 | my $fatal = 0 ; | ||||
343 | my $no_fatal = 0 ; | ||||
344 | |||||
345 | my $mask = ${^WARNING_BITS} ; | ||||
346 | |||||
347 | if (vec($mask, $Offsets{'all'}, 1)) { | ||||
348 | $mask |= $Bits{'all'} ; | ||||
349 | $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); | ||||
350 | } | ||||
351 | |||||
352 | push @_, 'all' unless @_; | ||||
353 | |||||
354 | foreach my $word ( @_ ) { | ||||
355 | if ($word eq 'FATAL') { | ||||
356 | $fatal = 1; | ||||
357 | $no_fatal = 0; | ||||
358 | } | ||||
359 | elsif ($word eq 'NONFATAL') { | ||||
360 | $fatal = 0; | ||||
361 | $no_fatal = 1; | ||||
362 | } | ||||
363 | elsif ($catmask = $Bits{$word}) { | ||||
364 | $mask |= $catmask ; | ||||
365 | $mask |= $DeadBits{$word} if $fatal ; | ||||
366 | $mask &= ~($DeadBits{$word}|$All) if $no_fatal ; | ||||
367 | } | ||||
368 | else | ||||
369 | { Croaker("Unknown warnings category '$word'")} | ||||
370 | } | ||||
371 | |||||
372 | ${^WARNING_BITS} = $mask ; | ||||
373 | } | ||||
374 | |||||
375 | sub unimport | ||||
376 | # spent 429µs within warnings::unimport which was called 28 times, avg 15µs/call:
# once (33µs+0s) by utf8::BEGIN@211 at line 211 of utf8_heavy.pl
# once (28µs+0s) by Moose::Exporter::BEGIN@386 at line 386 of Moose/Exporter.pm
# once (24µs+0s) by MRO::Compat::BEGIN@226 at line 226 of MRO/Compat.pm
# once (22µs+0s) by Test::More::BEGIN@1228 at line 1228 of Test/More.pm
# once (20µs+0s) by Class::MOP::Package::BEGIN@146 at line 146 of Class/MOP/Package.pm
# once (19µs+0s) by Test::Builder::BEGIN@857 at line 857 of Test/Builder.pm
# once (18µs+0s) by IO::Uncompress::Base::BEGIN@94 at line 94 of IO/Uncompress/Base.pm
# once (18µs+0s) by File::GlobMapper::BEGIN@341 at line 341 of File/GlobMapper.pm
# once (18µs+0s) by namespace::clean::BEGIN@190 at line 190 of namespace/clean.pm
# once (17µs+0s) by Moose::Object::BEGIN@98 at line 98 of Moose/Object.pm
# once (16µs+0s) by Moose::Util::TypeConstraints::BEGIN@592 at line 592 of Moose/Util/TypeConstraints.pm
# once (16µs+0s) by POSIX::BEGIN@40 at line 40 of POSIX.pm
# once (16µs+0s) by MRO::Compat::BEGIN@39 at line 39 of MRO/Compat.pm
# once (16µs+0s) by Test::More::BEGIN@1305 at line 1305 of Test/More.pm
# once (15µs+0s) by Test::Builder::BEGIN@1161 at line 1161 of Test/Builder.pm
# once (15µs+0s) by Moose::Meta::Role::BEGIN@523 at line 523 of Moose/Meta/Role.pm
# once (11µs+0s) by Class::MOP::Class::BEGIN@223 at line 223 of Class/MOP/Class.pm
# once (11µs+0s) by IO::Uncompress::Base::BEGIN@413 at line 413 of IO/Uncompress/Base.pm
# once (10µs+0s) by namespace::clean::BEGIN@383 at line 383 of namespace/clean.pm
# once (10µs+0s) by Test::More::BEGIN@1429 at line 1429 of Test/More.pm
# once (10µs+0s) by Moose::Meta::Role::BEGIN@544 at line 544 of Moose/Meta/Role.pm
# once (10µs+0s) by Test::More::BEGIN@1578 at line 1578 of Test/More.pm
# once (10µs+0s) by Class::MOP::Class::BEGIN@244 at line 244 of Class/MOP/Class.pm
# once (9µs+0s) by Exporter::Heavy::BEGIN@200 at line 200 of Exporter/Heavy.pm
# once (9µs+0s) by Moose::Util::TypeConstraints::BEGIN@619 at line 619 of Moose/Util/TypeConstraints.pm
# once (9µs+0s) by Carp::BEGIN@301 at line 301 of Carp/Heavy.pm
# once (8µs+0s) by Moose::Util::TypeConstraints::BEGIN@598 at line 598 of Moose/Util/TypeConstraints.pm
# once (8µs+0s) by Moose::Util::TypeConstraints::BEGIN@603 at line 603 of Moose/Util/TypeConstraints.pm | ||||
377 | 278 | 506µs | shift; | ||
378 | |||||
379 | my $catmask ; | ||||
380 | my $mask = ${^WARNING_BITS} ; | ||||
381 | |||||
382 | if (vec($mask, $Offsets{'all'}, 1)) { | ||||
383 | $mask |= $Bits{'all'} ; | ||||
384 | $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); | ||||
385 | } | ||||
386 | |||||
387 | push @_, 'all' unless @_; | ||||
388 | |||||
389 | foreach my $word ( @_ ) { | ||||
390 | if ($word eq 'FATAL') { | ||||
391 | next; | ||||
392 | } | ||||
393 | elsif ($catmask = $Bits{$word}) { | ||||
394 | $mask &= ~($catmask | $DeadBits{$word} | $All); | ||||
395 | } | ||||
396 | else | ||||
397 | { Croaker("Unknown warnings category '$word'")} | ||||
398 | } | ||||
399 | |||||
400 | ${^WARNING_BITS} = $mask ; | ||||
401 | } | ||||
402 | |||||
403 | 2 | 4µs | my %builtin_type; @builtin_type{qw(SCALAR ARRAY HASH CODE REF GLOB LVALUE Regexp)} = (); | ||
404 | |||||
405 | sub __chk | ||||
406 | { | ||||
407 | my $category ; | ||||
408 | my $offset ; | ||||
409 | my $isobj = 0 ; | ||||
410 | |||||
411 | if (@_) { | ||||
412 | # check the category supplied. | ||||
413 | $category = shift ; | ||||
414 | if (my $type = ref $category) { | ||||
415 | Croaker("not an object") | ||||
416 | if exists $builtin_type{$type}; | ||||
417 | $category = $type; | ||||
418 | $isobj = 1 ; | ||||
419 | } | ||||
420 | $offset = $Offsets{$category}; | ||||
421 | Croaker("Unknown warnings category '$category'") | ||||
422 | unless defined $offset; | ||||
423 | } | ||||
424 | else { | ||||
425 | $category = (caller(1))[0] ; | ||||
426 | $offset = $Offsets{$category}; | ||||
427 | Croaker("package '$category' not registered for warnings") | ||||
428 | unless defined $offset ; | ||||
429 | } | ||||
430 | |||||
431 | my $this_pkg = (caller(1))[0] ; | ||||
432 | my $i = 2 ; | ||||
433 | my $pkg ; | ||||
434 | |||||
435 | if ($isobj) { | ||||
436 | while (do { { package DB; $pkg = (caller($i++))[0] } } ) { | ||||
437 | last unless @DB::args && $DB::args[0] =~ /^$category=/ ; | ||||
438 | } | ||||
439 | $i -= 2 ; | ||||
440 | } | ||||
441 | else { | ||||
442 | $i = _error_loc(); # see where Carp will allocate the error | ||||
443 | } | ||||
444 | |||||
445 | my $callers_bitmask = (caller($i))[9] ; | ||||
446 | return ($callers_bitmask, $offset, $i) ; | ||||
447 | } | ||||
448 | |||||
449 | sub _error_loc { | ||||
450 | require Carp::Heavy; | ||||
451 | goto &Carp::short_error_loc; # don't introduce another stack frame | ||||
452 | } | ||||
453 | |||||
454 | sub enabled | ||||
455 | { | ||||
456 | Croaker("Usage: warnings::enabled([category])") | ||||
457 | unless @_ == 1 || @_ == 0 ; | ||||
458 | |||||
459 | my ($callers_bitmask, $offset, $i) = __chk(@_) ; | ||||
460 | |||||
461 | return 0 unless defined $callers_bitmask ; | ||||
462 | return vec($callers_bitmask, $offset, 1) || | ||||
463 | vec($callers_bitmask, $Offsets{'all'}, 1) ; | ||||
464 | } | ||||
465 | |||||
466 | |||||
467 | sub warn | ||||
468 | { | ||||
469 | Croaker("Usage: warnings::warn([category,] 'message')") | ||||
470 | unless @_ == 2 || @_ == 1 ; | ||||
471 | |||||
472 | my $message = pop ; | ||||
473 | my ($callers_bitmask, $offset, $i) = __chk(@_) ; | ||||
474 | require Carp; | ||||
475 | Carp::croak($message) | ||||
476 | if vec($callers_bitmask, $offset+1, 1) || | ||||
477 | vec($callers_bitmask, $Offsets{'all'}+1, 1) ; | ||||
478 | Carp::carp($message) ; | ||||
479 | } | ||||
480 | |||||
481 | sub warnif | ||||
482 | { | ||||
483 | Croaker("Usage: warnings::warnif([category,] 'message')") | ||||
484 | unless @_ == 2 || @_ == 1 ; | ||||
485 | |||||
486 | my $message = pop ; | ||||
487 | my ($callers_bitmask, $offset, $i) = __chk(@_) ; | ||||
488 | |||||
489 | return | ||||
490 | unless defined $callers_bitmask && | ||||
491 | (vec($callers_bitmask, $offset, 1) || | ||||
492 | vec($callers_bitmask, $Offsets{'all'}, 1)) ; | ||||
493 | |||||
494 | require Carp; | ||||
495 | Carp::croak($message) | ||||
496 | if vec($callers_bitmask, $offset+1, 1) || | ||||
497 | vec($callers_bitmask, $Offsets{'all'}+1, 1) ; | ||||
498 | |||||
499 | Carp::carp($message) ; | ||||
500 | } | ||||
501 | |||||
502 | 1 | 92µs | 1; | ||
503 | # ex: set ro: | ||||
# spent 4µs within warnings::CORE:match which was called
# once (4µs+0s) by Test::More::BEGIN@5 at line 13 of warnings.pm | |||||
# spent 16µs within warnings::CORE:regcomp which was called
# once (16µs+0s) by Test::More::BEGIN@5 at line 13 of warnings.pm |