← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm
StatementsExecuted 33157 statements in 68.2ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
134811159.6ms167msPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::violatesPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::violates
551110.2ms50.5msPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_has_topic_side_effectPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_has_topic_side_effect
321113.96ms9.37msPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_is_assignment_to_topicPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_assignment_to_topic
321111.59ms2.33msPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_is_topic_mutating_regexPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic_mutating_regex
321111.24ms4.13msPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_is_topic_mutating_funcPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic_mutating_func
321111.20ms2.40msPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_is_topicPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic
321111.06ms7.29msPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_is_topic_mutating_substrPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic_mutating_substr
14411291┬Ás291┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::applies_toPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::applies_to
3811155┬Ás209┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_is_assignment_operatorPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_assignment_operator
191177┬Ás99┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_is_increment_operatorPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_increment_operator
11174┬Ás103┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::supported_parametersPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::supported_parameters
11130┬Ás35┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::initialize_if_enabledPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::initialize_if_enabled
11116┬Ás16┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::BEGIN@10Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@10
11112┬Ás226┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::BEGIN@15Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@15
11110┬Ás13┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_get_cpan_list_funcsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_get_cpan_list_funcs
11110┬Ás21┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::BEGIN@11Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@11
1118┬Ás12┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::BEGIN@12Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@12
1118┬Ás703┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::BEGIN@17Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@17
1117┬Ás28┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::BEGIN@13Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@13
1117┬Ás59┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::BEGIN@21Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@21
1116┬Ás7┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::default_severityPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::default_severity
1113┬Ás3┬ÁsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_get_list_moreutils_funcsPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_get_list_moreutils_funcs
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::__ANON__[:209]Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::__ANON__[:209]
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::_is_binding_operatorPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_binding_operator
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::::default_themesPerl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::default_themes
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1##############################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##############################################################################
7
8package Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions;
9
10237┬Ás116┬Ás
# spent 16┬Ás within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@10 which was called: # once (16┬Ás+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11234┬Ás232┬Ás
# spent 21┬Ás (10+11) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@11 which was called: # once (10┬Ás+11┬Ás) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 21┬Ás making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@11 # spent 11┬Ás making 1 call to strict::import
12221┬Ás216┬Ás
# spent 12┬Ás (8+4) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@12 which was called: # once (8┬Ás+4┬Ás) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 12┬Ás making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@12 # spent 4┬Ás making 1 call to warnings::import
13223┬Ás248┬Ás
# spent 28┬Ás (7+20) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@13 which was called: # once (7┬Ás+20┬Ás) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 28┬Ás making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@13 # spent 20┬Ás making 1 call to Exporter::import
14
15232┬Ás2440┬Ás
# spent 226┬Ás (12+214) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@15 which was called: # once (12┬Ás+214┬Ás) by Module::Pluggable::Object::_require at line 15
use List::MoreUtils qw( none any );
# spent 226┬Ás making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@15 # spent 214┬Ás making 1 call to Exporter::Tiny::import
16
171200ns
# spent 703┬Ás (8+695) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@17 which was called: # once (8┬Ás+695┬Ás) by Module::Pluggable::Object::_require at line 19
use Perl::Critic::Utils qw{
18 :booleans :characters :severities :data_conversion :classification :ppi
19126┬Ás21.40ms};
# spent 703┬Ás making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@17 # spent 695┬Ás making 1 call to Exporter::import
20
212900┬Ás2111┬Ás
# spent 59┬Ás (7+52) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@21 which was called: # once (7┬Ás+52┬Ás) by Module::Pluggable::Object::_require at line 21
use base 'Perl::Critic::Policy';
# spent 59┬Ás making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::BEGIN@21 # spent 52┬Ás making 1 call to base::import
22
231600nsour $VERSION = '1.121';
24
25#-----------------------------------------------------------------------------
26
2712┬Ás130┬ÁsReadonly::Array my @BUILTIN_LIST_FUNCS => qw( map grep );
# spent 30┬Ás making 1 call to Readonly::Array
2815┬Ás242┬ÁsReadonly::Array my @CPAN_LIST_FUNCS => _get_cpan_list_funcs();
29
30#-----------------------------------------------------------------------------
31
32
# spent 13┬Ás (10+3) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_get_cpan_list_funcs which was called: # once (10┬Ás+3┬Ás) by Module::Pluggable::Object::_require at line 28
sub _get_cpan_list_funcs {
33 return qw( List::Util::first ),
3419┬Ás13┬Ás map { 'List::MoreUtils::'.$_ } _get_list_moreutils_funcs();
35}
36
37#-----------------------------------------------------------------------------
38
39
# spent 3┬Ás within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_get_list_moreutils_funcs which was called: # once (3┬Ás+0s) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_get_cpan_list_funcs at line 34
sub _get_list_moreutils_funcs {
4016┬Ás return qw(any all none notall true false firstidx first_index
41 lastidx last_index insert_after insert_after_string);
42}
43
44#-----------------------------------------------------------------------------
45
46
# spent 2.40ms (1.20+1.20) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic which was called 321 times, avg 7┬Ás/call: # 321 times (1.20ms+1.20ms) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_assignment_to_topic at line 134, avg 7┬Ás/call
sub _is_topic {
4732140┬Ás my $elem = shift;
483213.89ms3781.20ms return defined $elem
# spent 879┬Ás making 57 calls to PPI::Element::__eq, avg 15┬Ás/call # spent 323┬Ás making 321 calls to UNIVERSAL::isa, avg 1┬Ás/call
49 && $elem->isa('PPI::Token::Magic')
50 && $elem eq q{$_}; ##no critic (InterpolationOfMetachars)
51}
52
53
54#-----------------------------------------------------------------------------
55
5611┬Ás125┬ÁsReadonly::Scalar my $DESC => q{Don't modify $_ in list functions}; ##no critic (InterpolationOfMetachars)
# spent 25┬Ás making 1 call to Readonly::Scalar
5712┬Ás144┬ÁsReadonly::Scalar my $EXPL => [ 114 ];
# spent 44┬Ás making 1 call to Readonly::Scalar
58
59#-----------------------------------------------------------------------------
60
61
# spent 103┬Ás (74+30) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::supported_parameters which was called: # once (74┬Ás+30┬Ás) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
62 return (
63 {
64148┬Ás2030┬Ás name => 'list_funcs',
# spent 23┬Ás making 15 calls to Readonly::Array::FETCH, avg 2┬Ás/call # spent 4┬Ás making 3 calls to Readonly::Scalar::FETCH, avg 1┬Ás/call # spent 3┬Ás making 2 calls to Readonly::Array::FETCHSIZE, avg 2┬Ás/call
65 description => 'The base set of functions to check.',
66 default_string => join ($SPACE, @BUILTIN_LIST_FUNCS, @CPAN_LIST_FUNCS ),
67 behavior => 'string list',
68 },
69 {
70 name => 'add_list_funcs',
71 description => 'The set of functions to check, in addition to those given in list_funcs.',
72 default_string => $EMPTY,
73 behavior => 'string list',
74 },
75 );
76}
77
7812┬Ás
# spent 7┬Ás (6+1) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::default_severity which was called: # once (6┬Ás+1┬Ás) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm
sub default_severity { return $SEVERITY_HIGHEST }
79sub default_themes { return qw(core bugs pbp certrule ) }
80144375┬Ás
# spent 291┬Ás within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::applies_to which was called 144 times, avg 2┬Ás/call: # 144 times (291┬Ás+0s) by Perl::Critic::_critique at line 165 of Perl/Critic.pm, avg 2┬Ás/call
sub applies_to { return 'PPI::Token::Word' }
81
82#-----------------------------------------------------------------------------
83
84
# spent 35┬Ás (30+6) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::initialize_if_enabled which was called: # once (30┬Ás+6┬Ás) by Perl::Critic::Config::_add_policy_if_enabled at line 202 of Perl/Critic/Config.pm
sub initialize_if_enabled {
851400ns my ($self, $config) = @_;
86
87 $self->{_all_list_funcs} = {
88110┬Ás14┬Ás hashify keys %{ $self->{_list_funcs} }, keys %{ $self->{_add_list_funcs} }
# spent 4┬Ás making 1 call to Perl::Critic::Utils::hashify
89 };
90
9112┬Ás return $TRUE;
92}
93
94#-----------------------------------------------------------------------------
95
96
# spent 167ms (59.6+107) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::violates which was called 13481 times, avg 12┬Ás/call: # 13481 times (59.6ms+107ms) by Perl::Critic::_critique at line 183 of Perl/Critic.pm, avg 12┬Ás/call
sub violates {
97134812.90ms my ($self, $elem, $doc) = @_;
98
99 # Is this element a list function?
1001348146.8ms1348114.9ms return if not $self->{_all_list_funcs}->{$elem};
# spent 14.9ms making 13481 calls to PPI::Token::content, avg 1┬Ás/call
10155119┬Ás5539.3ms return if not is_function_call($elem);
# spent 39.3ms making 55 calls to Perl::Critic::Utils::is_function_call, avg 714┬Ás/call
102
103 # Only the block form of list functions can be analyzed.
10455239┬Ás1102.53ms return if not my $first_arg = first_arg( $elem );
# spent 2.50ms making 55 calls to Perl::Critic::Utils::first_arg, avg 45┬Ás/call # spent 30┬Ás making 55 calls to PPI::Util::TRUE, avg 540ns/call
10555179┬Ás5542┬Ás return if not $first_arg->isa('PPI::Structure::Block');
# spent 42┬Ás making 55 calls to UNIVERSAL::isa, avg 755ns/call
10655199┬Ás5550.5ms return if not $self->_has_topic_side_effect( $first_arg, $doc );
107
108 # Must be a violation
109 return $self->violation( $DESC, $EXPL, $elem );
110}
111
112#-----------------------------------------------------------------------------
113
114
# spent 50.5ms (10.2+40.2) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_has_topic_side_effect which was called 55 times, avg 917┬Ás/call: # 55 times (10.2ms+40.2ms) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::violates at line 106, avg 917┬Ás/call
sub _has_topic_side_effect {
1155525┬Ás my ( $self, $node, $doc ) = @_;
116
117 # Search through all significant elements in the block,
118 # testing each element to see if it mutates the topic.
11955108┬Ás5516.6ms my $tokens = $node->find( 'PPI::Token' ) || [];
# spent 16.6ms making 55 calls to PPI::Node::find, avg 302┬Ás/call
1205593┬Ás for my $elem ( @{ $tokens } ) {
121526628┬Ás526492┬Ás next if not $elem->significant();
# spent 283┬Ás making 321 calls to PPI::Element::significant, avg 882ns/call # spent 209┬Ás making 205 calls to PPI::Token::Whitespace::significant, avg 1┬Ás/call
122321341┬Ás3219.37ms return 1 if _is_assignment_to_topic( $elem );
123321395┬Ás3212.33ms return 1 if $self->_is_topic_mutating_regex( $elem, $doc );
124321331┬Ás3214.13ms return 1 if _is_topic_mutating_func( $elem );
125321454┬Ás3217.29ms return 1 if _is_topic_mutating_substr( $elem );
126 }
12755175┬Ás return;
128}
129
130#-----------------------------------------------------------------------------
131
132
# spent 9.37ms (3.96+5.42) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_assignment_to_topic which was called 321 times, avg 29┬Ás/call: # 321 times (3.96ms+5.42ms) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_has_topic_side_effect at line 122, avg 29┬Ás/call
sub _is_assignment_to_topic {
13332170┬Ás my $elem = shift;
134321716┬Ás3212.40ms return if not _is_topic( $elem );
# spent 2.40ms making 321 calls to Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic, avg 7┬Ás/call
135
1365791┬Ás571.39ms my $sib = $elem->snext_sibling();
# spent 1.39ms making 57 calls to PPI::Element::snext_sibling, avg 24┬Ás/call
13757287┬Ás114262┬Ás if ($sib && $sib->isa('PPI::Token::Operator')) {
# spent 209┬Ás making 38 calls to Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_assignment_operator, avg 5┬Ás/call # spent 31┬Ás making 38 calls to UNIVERSAL::isa, avg 818ns/call # spent 22┬Ás making 38 calls to PPI::Util::TRUE, avg 582ns/call
138 return 1 if _is_assignment_operator( $sib );
139 }
140
14157101┬Ás571.23ms my $psib = $elem->sprevious_sibling();
# spent 1.23ms making 57 calls to PPI::Element::sprevious_sibling, avg 22┬Ás/call
14257162┬Ás61127┬Ás if ($psib && $psib->isa('PPI::Token::Operator')) {
# spent 99┬Ás making 19 calls to Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_increment_operator, avg 5┬Ás/call # spent 15┬Ás making 21 calls to UNIVERSAL::isa, avg 724ns/call # spent 12┬Ás making 21 calls to PPI::Util::TRUE, avg 571ns/call
143 return 1 if _is_increment_operator( $psib );
144 }
145
14657128┬Ás return;
147}
148
149#-----------------------------------------------------------------------------
150
151
# spent 2.33ms (1.59+745┬Ás) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic_mutating_regex which was called 321 times, avg 7┬Ás/call: # 321 times (1.59ms+745┬Ás) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_has_topic_side_effect at line 123, avg 7┬Ás/call
sub _is_topic_mutating_regex {
15232189┬Ás my ( $self, $elem, $doc ) = @_;
1533212.45ms642745┬Ás return if ! ( $elem->isa('PPI::Token::Regexp::Substitute')
# spent 745┬Ás making 642 calls to UNIVERSAL::isa, avg 1┬Ás/call
154 || $elem->isa('PPI::Token::Regexp::Transliterate') );
155
156 # Exempt PPI::Token::Regexp::Transliterate objects IF the replacement
157 # string is empty AND neither the /d or /s flags are specified, OR the
158 # replacement string equals the match string AND neither the /c or /s
159 # flags are specified. RT 44515.
160 #
161 # NOTE that, at least as of 5.14.2, tr/// does _not_ participate in the
162 # 'use re /modifiers' mechanism. And a good thing, too, since the
163 # modifiers that _are_ common (/s and /d) mean something completely
164 # different in tr///.
165 if ( $elem->isa( 'PPI::Token::Regexp::Transliterate') ) {
166 my $subs = $elem->get_substitute_string();
167 my %mods = $elem->get_modifiers();
168 $mods{r} and return; # Introduced in Perl 5.13.7
169 if ( $EMPTY eq $subs ) {
170 $mods{d} or $mods{s} or return;
171 } elsif ( $elem->get_match_string() eq $subs ) {
172 $mods{c} or $mods{s} or return;
173 }
174 }
175
176 # As of 5.13.2, the substitute built-in supports the /r modifier, which
177 # causes the operation to return the modified string and leave the
178 # original unmodified. This does not parse under earlier Perls, so there
179 # is no version check.
180
181 if ( $elem->isa( 'PPI::Token::Regexp::Substitute' ) ) {
182 my $re = $doc->ppix_regexp_from_element( $elem )
183 or return;
184 $re->modifier_asserted( 'r' )
185 and return;
186 }
187
188 # If the previous sibling does not exist, then
189 # the regex implicitly binds to $_
190 my $prevsib = $elem->sprevious_sibling;
191 return 1 if not $prevsib;
192
193 # If the previous sibling does exist, then it
194 # should be a binding operator.
195 return 1 if not _is_binding_operator( $prevsib );
196
197 # Check if the sibling before the biding operator
198 # is explicitly set to $_
199 my $bound_to = $prevsib->sprevious_sibling;
200 return _is_topic( $bound_to );
201}
202
203#-----------------------------------------------------------------------------
204
205
# spent 4.13ms (1.24+2.89) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic_mutating_func which was called 321 times, avg 13┬Ás/call: # 321 times (1.24ms+2.89ms) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_has_topic_side_effect at line 124, avg 13┬Ás/call
sub _is_topic_mutating_func {
20632161┬Ás my $elem = shift;
2073211.38ms321280┬Ás return if not $elem->isa('PPI::Token::Word');
# spent 280┬Ás making 321 calls to UNIVERSAL::isa, avg 873ns/call
2084253┬Ás my @mutator_funcs = qw(chop chomp undef);
209168479┬Ás1683.92ms return if not any { $elem eq $_ } @mutator_funcs;
# spent 2.14ms making 42 calls to List::MoreUtils::any, avg 51┬Ás/call # spent 1.78ms making 126 calls to PPI::Element::__eq, avg 14┬Ás/call
21011┬Ás1431┬Ás return if not is_function_call( $elem );
# spent 431┬Ás making 1 call to Perl::Critic::Utils::is_function_call
211
212 # If these functions have no argument,
213 # they default to mutating $_
21411┬Ás126┬Ás my $first_arg = first_arg( $elem );
# spent 26┬Ás making 1 call to Perl::Critic::Utils::first_arg
2151400ns if (not defined $first_arg) {
216 # undef does not default to $_, unlike the others
21714┬Ás114┬Ás return if $elem eq 'undef';
# spent 14┬Ás making 1 call to PPI::Element::__eq
218 return 1;
219 }
220 return _is_topic( $first_arg );
221}
222
223#-----------------------------------------------------------------------------
224
22511┬Ás121┬ÁsReadonly::Scalar my $MUTATING_SUBSTR_ARG_COUNT => 4;
# spent 21┬Ás making 1 call to Readonly::Scalar
226
227
# spent 7.29ms (1.06+6.24) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_topic_mutating_substr which was called 321 times, avg 23┬Ás/call: # 321 times (1.06ms+6.24ms) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_has_topic_side_effect at line 125, avg 23┬Ás/call
sub _is_topic_mutating_substr {
22832156┬Ás my $elem = shift;
2293213.39ms3215.37ms return if $elem ne 'substr';
# spent 5.37ms making 321 calls to PPI::Element::__ne, avg 17┬Ás/call
230118┬Ás1432┬Ás return if not is_function_call( $elem );
# spent 432┬Ás making 1 call to Perl::Critic::Utils::is_function_call
231
232 # check and see if the first arg is $_
23313┬Ás1433┬Ás my @args = parse_arg_list( $elem );
# spent 433┬Ás making 1 call to Perl::Critic::Utils::parse_arg_list
23415┬Ás11┬Ás return @args >= $MUTATING_SUBSTR_ARG_COUNT && _is_topic( $args[0]->[0] );
# spent 1┬Ás making 1 call to Readonly::Scalar::FETCH
235}
236
237#-----------------------------------------------------------------------------
238
239{
240 ##no critic(ArgUnpacking)
241
242212┬Ás17┬Ás my %assignment_ops = hashify qw(
# spent 7┬Ás making 1 call to Perl::Critic::Utils::hashify
243 = *= /= += -= %= **= x= .= &= |= ^= &&= ||= <<= >>= //= ++ --
244 );
24538134┬Ás3854┬Ás
# spent 209┬Ás (155+54) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_assignment_operator which was called 38 times, avg 5┬Ás/call: # 38 times (155┬Ás+54┬Ás) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_assignment_to_topic at line 137, avg 5┬Ás/call
sub _is_assignment_operator { return exists $assignment_ops{$_[0]} }
# spent 54┬Ás making 38 calls to PPI::Token::content, avg 1┬Ás/call
246
24712┬Ás12┬Ás my %increment_ops = hashify qw( ++ -- );
# spent 2┬Ás making 1 call to Perl::Critic::Utils::hashify
2481970┬Ás1922┬Ás
# spent 99┬Ás (77+22) within Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_increment_operator which was called 19 times, avg 5┬Ás/call: # 19 times (77┬Ás+22┬Ás) by Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::_is_assignment_to_topic at line 142, avg 5┬Ás/call
sub _is_increment_operator { return exists $increment_ops{$_[0]} }
# spent 22┬Ás making 19 calls to PPI::Token::content, avg 1┬Ás/call
249
25012┬Ás12┬Ás my %binding_ops = hashify qw( =~ !~ );
# spent 2┬Ás making 1 call to Perl::Critic::Utils::hashify
251 sub _is_binding_operator { return exists $binding_ops{$_[0]} }
252}
253
25419┬Ás1;
255
256#-----------------------------------------------------------------------------
257
258__END__