]> git.donarmstrong.com Git - perltidy.git/commitdiff
optimization
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 25 Oct 2023 14:51:01 +0000 (07:51 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 25 Oct 2023 14:51:01 +0000 (07:51 -0700)
lib/Perl/Tidy/Tokenizer.pm

index 677843faa198d41940327f92689cf91997f59171..b533a646d12ddee3094f2a93588e2e383afd9e48 100644 (file)
@@ -5856,7 +5856,11 @@ EOM
                 push( @tokens, substr( $input_line, $offset, $numc ) );
                 $offset += $numc;
 
-                if ( DEVEL_MODE && $numc <= 0 ) {
+                # programming note: it is most efficient to 'next' out of
+                # a critical loop like this as early as possible. So instead
+                # of 'if ( DEVEL_MODE && $numc < 0 )' we should write:
+                next unless DEVEL_MODE;
+                if ( $numc <= 0 ) {
 
                     # Should not happen unless @{$rtoken_map} is corrupted
                     $self->Fault(