_rseqno_controlling_my_ci_ => $i++,
_ris_seqno_controlling_ci_ => $i++,
+ _save_logfile_ => $i++,
};
$self->[_rspecial_side_comment_type_] = {};
+ # This flag will be updated later by a call to get_save_logfile()
+ $self->[_save_logfile_] = defined($logger_object);
+
bless $self, $class;
# Safety check..this is not a class yet
return;
}
+ # Update the 'save_logfile' flag based to include any tokenization errors.
+ # We can save time by skipping logfile calls if it is not going to be saved.
+ my $logger_object = $self->[_logger_object_];
+ if ($logger_object) {
+ $self->[_save_logfile_] = $logger_object->get_save_logfile();
+ }
+
# Make a pass through the lines, looking at lines of CODE and identifying
# special processing needs, such format skipping sections marked by
# special comments
my $file_writer_object = $self->[_file_writer_object_];
my $logger_object = $self->[_logger_object_];
my $vertical_aligner_object = $self->[_vertical_aligner_object_];
+ my $save_logfile = $self->[_save_logfile_];
# Note for RT#118553, leave only one newline at the end of a file.
# Example code to do this is in comments below:
}
else {
- # let logger see all non-blank lines of code
- if ($logger_object) {
+ # Let logger see all non-blank lines of code. This is a slow operation
+ # so we avoid it if it is not going to be saved.
+ if ( $save_logfile && $logger_object ) {
$logger_object->black_box( $line_of_tokens,
$vertical_aligner_object->get_output_line_number );
}
return;
}
+sub get_save_logfile {
+
+ # To be called after tokenizer has finished to make formatting more
+ # efficient. This is not precisely the same as the check used below
+ # because we don't yet have the syntax check result, but since syntax
+ # checking is off by default it will be the same except in debug runs with
+ # syntax checking activated. In that case it will tell the formatter to
+ # save the logfile even if it may actually be deleted based on the syntax
+ # check.
+ my $self = shift;
+ my $saw_code_bug = $self->{_saw_code_bug};
+ my $rOpts = $self->{_rOpts};
+ return
+ $saw_code_bug == 1
+ || $rOpts->{'logfile'}
+ || $rOpts->{'check-syntax'};
+}
+
sub finish {
# called after all formatting to summarize errors
- review tickets at [rt.cpan.org](https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy)
- review the issues at [github](https://github.com/perltidy/perltidy/issues/)
-- compare the new version with previous version on all files in test area
+- compare formatting with the new version with previous version on all files in test area
+- run a blinker test (activate option -I and look for 'Blinker' in DIAGNOSTICS)
+- run a timing test: compare run time with previous version
+- profile with 'nytprof' and compare with previous version
- run random testing on final version for a significant time before releasing (several days)
- run 'author tests' on a much larger body of code than is covered by the .t
files.