← Index
NYTProf Performance Profile   « line view »
For rbm/rbm
  Run on Wed Feb 12 20:36:06 2020
Reported on Wed Feb 12 21:42:27 2020

Filename/usr/share/perl/5.28/locale.pm
StatementsExecuted 11 statements in 474µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11118µs33µslocale::::BEGIN@4locale::BEGIN@4
1115µs5µslocale::::importlocale::import
0000s0slocale::::unimportlocale::unimport
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package locale;
2
31300nsour $VERSION = '1.09';
42460µs248µs
# spent 33µs (18+15) within locale::BEGIN@4 which was called: # once (18µs+15µs) by Template::Filters::BEGIN@24 at line 4
use Config;
# spent 33µs making 1 call to locale::BEGIN@4 # spent 15µs making 1 call to Config::import
5
611µs$Carp::Internal{ (__PACKAGE__) } = 1;
7
8# A separate bit is used for each of the two forms of the pragma, to save
9# having to look at %^H for the normal case of a plain 'use locale' without an
10# argument.
11
121100ns$locale::hint_bits = 0x4;
131100ns$locale::partial_hint_bits = 0x10; # If pragma has an argument
14
15# The pseudo-category :characters consists of 2 real ones; but it also is
16# given its own number, -1, because in the complement form it also has the
17# side effect of "use feature 'unicode_strings'"
18
19
# spent 5µs within locale::import which was called: # once (5µs+0s) by Template::Filters::BEGIN@24 at line 24 of Template/Filters.pm
sub import {
201100ns shift; # should be 'locale'; not checked
21
2212µs $^H{locale} = 0 unless defined $^H{locale};
2315µs if (! @_) { # If no parameter, use the plain form that changes all categories
2411µs $^H |= $locale::hint_bits;
25
26 }
27 else {
28 my @categories = ( qw(:ctype :collate :messages
29 :numeric :monetary :time) );
30 for (my $i = 0; $i < @_; $i++) {
31 my $arg = $_[$i];
32 $complement = $arg =~ s/ : ( ! | not_ ) /:/x;
33 if (! grep { $arg eq $_ } @categories, ":characters") {
34 require Carp;
35 Carp::croak("Unknown parameter '$_[$i]' to 'use locale'");
36 }
37
38 if ($complement) {
39 if ($i != 0 || $i < @_ - 1) {
40 require Carp;
41 Carp::croak("Only one argument to 'use locale' allowed"
42 . "if is $complement");
43 }
44
45 if ($arg eq ':characters') {
46 push @_, grep { $_ ne ':ctype' && $_ ne ':collate' }
47 @categories;
48 # We add 1 to the category number; This category number
49 # is -1
50 $^H{locale} |= (1 << 0);
51 }
52 else {
53 push @_, grep { $_ ne $arg } @categories;
54 }
55 next;
56 }
57 elsif ($arg eq ':characters') {
58 push @_, ':ctype', ':collate';
59 next;
60 }
61
62 $^H |= $locale::partial_hint_bits;
63
64 # This form of the pragma overrides the other
65 $^H &= ~$locale::hint_bits;
66
67 $arg =~ s/^://;
68
69 eval { require POSIX; import POSIX 'locale_h'; };
70
71 # Map our names to the ones defined by POSIX
72 my $LC = "LC_" . uc($arg);
73
74 my $bit = eval "&POSIX::$LC";
75 if (defined $bit) { # XXX Should we warn that this category isn't
76 # supported on this platform, or make it
77 # always be the C locale?
78
79 # Verify our assumption.
80 if (! ($bit >= 0 && $bit < 31)) {
81 require Carp;
82 Carp::croak("Cannot have ':$arg' parameter to 'use locale'"
83 . " on this platform. Use the 'perlbug' utility"
84 . " to report this problem, or send email to"
85 . " 'perlbug\@perl.org'. $LC=$bit");
86 }
87
88 # 1 is added so that the pseudo-category :characters, which is
89 # -1, comes out 0.
90 $^H{locale} |= 1 << ($bit + 1);
91 }
92 }
93 }
94
95}
96
97sub unimport {
98 $^H &= ~($locale::hint_bits|$locale::partial_hint_bits);
99 $^H{locale} = 0;
100}
101
10214µs1;