← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:09 2015

Filename/usr/share/perl5/locale.pm
StatementsExecuted 41 statements in 88µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
99949µs49µ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
31900nsour $VERSION = '1.01';
4
512µs$Carp::Internal{ (__PACKAGE__) } = 1;
6
7=head1 NAME
8
9locale - Perl pragma to use or avoid POSIX locales for built-in operations
10
11=head1 SYNOPSIS
12
13 @x = sort @y; # Unicode sorting order
14 {
15 use locale;
16 @x = sort @y; # Locale-defined sorting order
17 }
18 @x = sort @y; # Unicode sorting order again
19
20=head1 DESCRIPTION
21
22This pragma tells the compiler to enable (or disable) the use of POSIX
23locales for built-in operations (for example, LC_CTYPE for regular
24expressions, LC_COLLATE for string comparison, and LC_NUMERIC for number
25formatting). Each "use locale" or "no locale"
26affects statements to the end of the enclosing BLOCK.
27
28Starting in Perl 5.16, a hybrid mode for this pragma is available,
29
30 use locale ':not_characters';
31
32which enables only the portions of locales that don't affect the character
33set (that is, all except LC_COLLATE and LC_CTYPE). This is useful when mixing
34Unicode and locales, including UTF-8 locales.
35
36 use locale ':not_characters';
37 use open ":locale"; # Convert I/O to/from Unicode
38 use POSIX qw(locale_h); # Import the LC_ALL constant
39 setlocale(LC_ALL, ""); # Required for the next statement
40 # to take effect
41 printf "%.2f\n", 12345.67' # Locale-defined formatting
42 @x = sort @y; # Unicode-defined sorting order.
43 # (Note that you will get better
44 # results using Unicode::Collate.)
45
46See L<perllocale> for more detailed information on how Perl supports
47locales.
48
49=cut
50
51# A separate bit is used for each of the two forms of the pragma, as they are
52# mostly independent, and interact with each other and the unicode_strings
53# feature. This allows for fast determination of which one(s) of the three
54# are to be used at any given point, and no code has to be written to deal
55# with coming in and out of scopes--it falls automatically out from the hint
56# handling
57
581300ns$locale::hint_bits = 0x4;
591200ns$locale::not_chars_hint_bits = 0x10;
60
61
# spent 49µs within locale::import which was called 9 times, avg 5µs/call: # once (9µs+0s) by Foswiki::Render::BEGIN@92 at line 97 of /var/www/foswiki11/lib/Foswiki/Render.pm # once (7µs+0s) by Assert::BEGIN@19 at line 19 of /var/www/foswiki11/lib/Assert.pm # once (6µs+0s) by Foswiki::Plugins::InterwikiPlugin::BEGIN@40 at line 45 of /var/www/foswiki11/lib/Foswiki/Plugins/InterwikiPlugin.pm # once (6µs+0s) by Foswiki::BEGIN@137 at line 346 of /var/www/foswiki11/lib/Foswiki.pm # once (5µs+0s) by Foswiki::Store::VC::Store::BEGIN@46 at line 51 of /var/www/foswiki11/lib/Foswiki/Store/VC/Store.pm # once (5µs+0s) by Foswiki::Search::BEGIN@26 at line 33 of /var/www/foswiki11/lib/Foswiki/Search.pm # once (4µs+0s) by Foswiki::Plugins::FindElsewherePlugin::Core::BEGIN@25 at line 29 of /var/www/foswiki11/lib/Foswiki/Plugins/FindElsewherePlugin/Core.pm # once (4µs+0s) by Foswiki::Store::VC::Handler::BEGIN@41 at line 44 of /var/www/foswiki11/lib/Foswiki/Store/VC/Handler.pm # once (4µs+0s) by Foswiki::Users::new at line 84 of /var/www/foswiki11/lib/Foswiki/Users.pm
sub import {
6294µs shift; # should be 'locale'; not checked
6395µs my $found_not_chars = 0;
64911µs while (defined (my $arg = shift)) {
65 if ($arg eq ":not_characters") {
66 $^H |= $locale::not_chars_hint_bits;
67
68 # This form of the pragma overrides the other
69 $^H &= ~$locale::hint_bits;
70 $found_not_chars = 1;
71 }
72 else {
73 require Carp;
74 Carp::croak("Unknown parameter '$arg' to 'use locale'");
75 }
76 }
77
78 # Use the plain form if not doing the :not_characters one.
79959µs $^H |= $locale::hint_bits unless $found_not_chars;
80}
81
82sub unimport {
83 $^H &= ~($locale::hint_bits|$locale::not_chars_hint_bits);
84}
85
8617µs1;