← Index
NYTProf Performance Profile   « line view »
For -e
  Run on Thu Jun 30 16:16:00 2016
Reported on Thu Jun 30 16:16:08 2016

Filename/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/5.22.1/x86_64-linux/re.pm
StatementsExecuted 36 statements in 2.41ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11125µs28µsre::::BEGIN@4re::BEGIN@4
11115µs15µsre::::bitsre::bits
11111µs18µsre::::BEGIN@5re::BEGIN@5
11111µs26µsre::::importre::import
0000s0sre::::_load_unloadre::_load_unload
0000s0sre::::setcolorre::setcolor
0000s0sre::::unimportre::unimport
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package re;
2
3# pragma for controlling the regexp engine
4242µs232µs
# spent 28µs (25+4) within re::BEGIN@4 which was called: # once (25µs+4µs) by DateTime::Format::Alami::BEGIN@114 at line 4
use strict;
# spent 28µs making 1 call to re::BEGIN@4 # spent 4µs making 1 call to strict::import
521.82ms226µs
# spent 18µs (11+7) within re::BEGIN@5 which was called: # once (11µs+7µs) by DateTime::Format::Alami::BEGIN@114 at line 5
use warnings;
# spent 18µs making 1 call to re::BEGIN@5 # spent 7µs making 1 call to warnings::import
6
71700nsour $VERSION = "0.32";
8110µsour @ISA = qw(Exporter);
911µsour @EXPORT_OK = ('regmust',
10 qw(is_regexp regexp_pattern
11 regname regnames regnames_count));
1217µsour %EXPORT_OK = map { $_ => 1 } @EXPORT_OK;
13
1411µsmy %bitmask = (
15 taint => 0x00100000, # HINT_RE_TAINT
16 eval => 0x00200000, # HINT_RE_EVAL
17);
18
191300nsmy $flags_hint = 0x02000000; # HINT_RE_FLAGS
201100nsmy $PMMOD_SHIFT = 0;
2118µsmy %reflags = (
22 m => 1 << ($PMMOD_SHIFT + 0),
23 s => 1 << ($PMMOD_SHIFT + 1),
24 i => 1 << ($PMMOD_SHIFT + 2),
25 x => 1 << ($PMMOD_SHIFT + 3),
26 n => 1 << ($PMMOD_SHIFT + 5),
27 p => 1 << ($PMMOD_SHIFT + 6),
28 strict => 1 << ($PMMOD_SHIFT + 10),
29# special cases:
30 d => 0,
31 l => 1,
32 u => 2,
33 a => 3,
34 aa => 4,
35);
36
37sub setcolor {
38 eval { # Ignore errors
39 require Term::Cap;
40
41 my $terminal = Tgetent Term::Cap ({OSPEED => 9600}); # Avoid warning.
42 my $props = $ENV{PERL_RE_TC} || 'md,me,so,se,us,ue';
43 my @props = split /,/, $props;
44 my $colors = join "\t", map {$terminal->Tputs($_,1)} @props;
45
46 $colors =~ s/\0//g;
47 $ENV{PERL_RE_COLORS} = $colors;
48 };
49 if ($@) {
50 $ENV{PERL_RE_COLORS} ||= qq'\t\t> <\t> <\t\t';
51 }
52
53}
54
5518µsmy %flags = (
56 COMPILE => 0x0000FF,
57 PARSE => 0x000001,
58 OPTIMISE => 0x000002,
59 TRIEC => 0x000004,
60 DUMP => 0x000008,
61 FLAGS => 0x000010,
62 TEST => 0x000020,
63
64 EXECUTE => 0x00FF00,
65 INTUIT => 0x000100,
66 MATCH => 0x000200,
67 TRIEE => 0x000400,
68
69 EXTRA => 0xFF0000,
70 TRIEM => 0x010000,
71 OFFSETS => 0x020000,
72 OFFSETSDBG => 0x040000,
73 STATE => 0x080000,
74 OPTIMISEM => 0x100000,
75 STACK => 0x280000,
76 BUFFERS => 0x400000,
77 GPOS => 0x800000,
78);
7912µs$flags{ALL} = -1 & ~($flags{OFFSETS}|$flags{OFFSETSDBG}|$flags{BUFFERS});
801700ns$flags{All} = $flags{all} = $flags{DUMP} | $flags{EXECUTE};
811600ns$flags{Extra} = $flags{EXECUTE} | $flags{COMPILE} | $flags{GPOS};
821800ns$flags{More} = $flags{MORE} = $flags{All} | $flags{TRIEC} | $flags{TRIEM} | $flags{STATE};
831400ns$flags{State} = $flags{DUMP} | $flags{EXECUTE} | $flags{STATE};
841500ns$flags{TRIE} = $flags{DUMP} | $flags{EXECUTE} | $flags{TRIEC};
85
8611µsif (defined &DynaLoader::boot_DynaLoader) {
871700ns require XSLoader;
881457µs1445µs XSLoader::load();
# spent 445µs making 1 call to XSLoader::load
89}
90# else we're miniperl
91# We need to work for miniperl, because the XS toolchain uses Text::Wrap, which
92# uses re 'taint'.
93
94sub _load_unload {
95 my ($on)= @_;
96 if ($on) {
97 # We call install() every time, as if we didn't, we wouldn't
98 # "see" any changes to the color environment var since
99 # the last time it was called.
100
101 # install() returns an integer, which if casted properly
102 # in C resolves to a structure containing the regexp
103 # hooks. Setting it to a random integer will guarantee
104 # segfaults.
105 $^H{regcomp} = install();
106 } else {
107 delete $^H{regcomp};
108 }
109}
110
111
# spent 15µs within re::bits which was called: # once (15µs+0s) by re::import at line 275
sub bits {
1121400ns my $on = shift;
1131200ns my $bits = 0;
11411µs my $turning_all_off = ! @_ && ! $on;
1151300ns my %seen; # Has flag already been seen?
1161200ns if ($turning_all_off) {
117
118 # Pretend were called with certain parameters, which are best dealt
119 # with that way.
120 push @_, keys %bitmask; # taint and eval
121 push @_, 'strict';
122 }
123
124 # Process each subpragma parameter
125 ARG:
12616µs foreach my $idx (0..$#_){
1271900ns my $s=$_[$idx];
12813µs if ($s eq 'Debug' or $s eq 'Debugcolor') {
129 setcolor() if $s =~/color/i;
130 ${^RE_DEBUG_FLAGS} = 0 unless defined ${^RE_DEBUG_FLAGS};
131 for my $idx ($idx+1..$#_) {
132 if ($flags{$_[$idx]}) {
133 if ($on) {
134 ${^RE_DEBUG_FLAGS} |= $flags{$_[$idx]};
135 } else {
136 ${^RE_DEBUG_FLAGS} &= ~ $flags{$_[$idx]};
137 }
138 } else {
139 require Carp;
140 Carp::carp("Unknown \"re\" Debug flag '$_[$idx]', possible flags: ",
141 join(", ",sort keys %flags ) );
142 }
143 }
144 _load_unload($on ? 1 : ${^RE_DEBUG_FLAGS});
145 last;
146 } elsif ($s eq 'debug' or $s eq 'debugcolor') {
147 setcolor() if $s =~/color/i;
148 _load_unload($on);
149 last;
150 } elsif (exists $bitmask{$s}) {
151 $bits |= $bitmask{$s};
152 } elsif ($EXPORT_OK{$s}) {
153 require Exporter;
154 re->export_to_level(2, 're', $s);
155 } elsif ($s eq 'strict') {
156 if ($on) {
157 $^H{reflags} |= $reflags{$s};
158 warnings::warnif('experimental::re_strict',
159 "\"use re 'strict'\" is experimental");
160
161 # Turn on warnings if not already done.
162 if (! warnings::enabled('regexp')) {
163 require warnings;
164 warnings->import('regexp');
165 $^H{re_strict} = 1;
166 }
167 }
168 else {
169 $^H{reflags} &= ~$reflags{$s} if $^H{reflags};
170
171 # Turn off warnings if we turned them on.
172 warnings->unimport('regexp') if $^H{re_strict};
173 }
174 if ($^H{reflags}) {
175 $^H |= $flags_hint;
176 }
177 else {
178 $^H &= ~$flags_hint;
179 }
180 } elsif ($s =~ s/^\///) {
181 my $reflags = $^H{reflags} || 0;
182 my $seen_charset;
183 while ($s =~ m/( . )/gx) {
184 local $_ = $1;
185 if (/[adul]/) {
186 # The 'a' may be repeated; hide this from the rest of the
187 # code by counting and getting rid of all of them, then
188 # changing to 'aa' if there is a repeat.
189 if ($_ eq 'a') {
190 my $sav_pos = pos $s;
191 my $a_count = $s =~ s/a//g;
192 pos $s = $sav_pos - 1; # -1 because got rid of the 'a'
193 if ($a_count > 2) {
194 require Carp;
195 Carp::carp(
196 qq 'The "a" flag may only appear a maximum of twice'
197 );
198 }
199 elsif ($a_count == 2) {
200 $_ = 'aa';
201 }
202 }
203 if ($on) {
204 if ($seen_charset) {
205 require Carp;
206 if ($seen_charset ne $_) {
207 Carp::carp(
208 qq 'The "$seen_charset" and "$_" flags '
209 .qq 'are exclusive'
210 );
211 }
212 else {
213 Carp::carp(
214 qq 'The "$seen_charset" flag may not appear '
215 .qq 'twice'
216 );
217 }
218 }
219 $^H{reflags_charset} = $reflags{$_};
220 $seen_charset = $_;
221 }
222 else {
223 delete $^H{reflags_charset}
224 if defined $^H{reflags_charset}
225 && $^H{reflags_charset} == $reflags{$_};
226 }
227 } elsif (exists $reflags{$_}) {
228 $seen{$_}++;
229 $on
230 ? $reflags |= $reflags{$_}
231 : ($reflags &= ~$reflags{$_});
232 } else {
233 require Carp;
234 Carp::carp(
235 qq'Unknown regular expression flag "$_"'
236 );
237 next ARG;
238 }
239 }
240 ($^H{reflags} = $reflags or defined $^H{reflags_charset})
241 ? $^H |= $flags_hint
242 : ($^H &= ~$flags_hint);
243 } else {
244 require Carp;
245 Carp::carp("Unknown \"re\" subpragma '$s' (known ones are: ",
246 join(', ', map {qq('$_')} 'debug', 'debugcolor', sort keys %bitmask),
247 ")");
248 }
249 }
2501400ns if (exists $seen{'x'} && $seen{'x'} > 1
251 && (warnings::enabled("deprecated")
252 || warnings::enabled("regexp")))
253 {
254 my $message = "Having more than one /x regexp modifier is deprecated";
255 if (warnings::enabled("deprecated")) {
256 warnings::warn("deprecated", $message);
257 }
258 else {
259 warnings::warn("regexp", $message);
260 }
261 }
262
2631200ns if ($turning_all_off) {
264 _load_unload(0);
265 $^H{reflags} = 0;
266 $^H{reflags_charset} = 0;
267 $^H &= ~$flags_hint;
268 }
269
27017µs $bits;
271}
272
273
# spent 26µs (11+15) within re::import which was called: # once (11µs+15µs) by DateTime::Format::Alami::BEGIN@114 at line 114 of DateTime/Format/Alami.pm
sub import {
2741400ns shift;
27517µs115µs $^H |= bits(1, @_);
# spent 15µs making 1 call to re::bits
276}
277
278sub unimport {
279 shift;
280 $^H &= ~ bits(0, @_);
281}
282
283125µs1;
284
285__END__