@iprev_to_go,
@parent_seqno_to_go,
+ # forced breakpoint variables associated with each batch of code
+ $forced_breakpoint_count,
+ $forced_breakpoint_undo_count,
+ $index_max_forced_break,
);
BEGIN {
$index_start_one_line_block = UNDEFINED_INDEX;
$semicolons_before_block_self_destruct = 0;
- initialize_forced_breakpoint_vars();
+ # initialize forced breakpoint vars associated with each output batch
+ $forced_breakpoint_count = 0;
+ $index_max_forced_break = UNDEFINED_INDEX;
+ $forced_breakpoint_undo_count = 0;
return;
}
my $block_type = $rblock_type_of_seqno->{$type_sequence};
$block_type = "" unless ( defined($block_type) );
- my $index_max_forced_break = get_index_max_forced_break();
my $previous_nonblank_token = '';
my $i_last_nonblank = -1;
{ ## begin closure set_forced_breakpoint
- my $forced_breakpoint_count;
- my $forced_breakpoint_undo_count;
my @forced_breakpoint_undo_stack;
- my $index_max_forced_break;
+
+ # These are global vars for efficiency:
+ # my $forced_breakpoint_count;
+ # my $forced_breakpoint_undo_count;
+ # my $index_max_forced_break;
# Break before or after certain tokens based on user settings
my %break_before_or_after_token;
@break_before_or_after_token{@q} = (1) x scalar(@q);
}
+ # This is no longer called - global vars - moved into initialize_batch_vars
sub initialize_forced_breakpoint_vars {
$forced_breakpoint_count = 0;
$index_max_forced_break = UNDEFINED_INDEX;
return;
}
- sub get_forced_breakpoint_count {
- return $forced_breakpoint_count;
- }
-
- sub get_forced_breakpoint_undo_count {
- return $forced_breakpoint_undo_count;
- }
-
- sub get_index_max_forced_break {
- return $index_max_forced_break;
- }
-
sub set_fake_breakpoint {
# Just bump up the breakpoint count as a signal that there are breaks.
&& !$saw_good_break
# and we don't already have an interior breakpoint
- && !get_forced_breakpoint_count()
+ && !$forced_breakpoint_count
)
)
{
# the same breakpoints will occur. scbreak.t
if (
$i_test == $imax # we are at the end
- && !get_forced_breakpoint_count()
+ && !$forced_breakpoint_count
&& $saw_good_break # old line had good break
&& $type =~ /^[#;\{]$/ # and this line ends in
# ';' or side comment
# handle commas within containers...
elsif ($real_comma_count) {
- my $fbc = get_forced_breakpoint_count();
+ my $fbc = $forced_breakpoint_count;
# always open comma lists not preceded by keywords,
# barewords, identifiers (that is, anything that doesn't
has_broken_sublist => $has_broken_sublist[$dd],
}
);
- $bp_count = get_forced_breakpoint_count() - $fbc;
+ $bp_count = $forced_breakpoint_count - $fbc;
$do_not_break_apart = 0 if $must_break_open;
}
}
$last_old_breakpoint_count = 0;
$minimum_depth = $current_depth + 1; # forces update in check below
$old_breakpoint_count = 0;
- $starting_breakpoint_count = get_forced_breakpoint_count();
+ $starting_breakpoint_count = $forced_breakpoint_count;
$token = ';';
$type = ';';
$type_sequence = '';
&& $type_sequence
&& $self->[_roverride_cab3_]->{$type_sequence};
- $breakpoint_stack[$depth] = get_forced_breakpoint_count();
+ $breakpoint_stack[$depth] = $forced_breakpoint_count;
$container_type[$depth] =
# k => && || ? : .
$last_nonblank_type[$depth] = $last_nonblank_type;
$opening_structure_index_stack[$depth] = $i;
- $breakpoint_undo_stack[$depth] =
- get_forced_breakpoint_undo_count();
- $comma_index[$depth] = undef;
- $last_comma_index[$depth] = undef;
- $last_dot_index[$depth] = undef;
+ $breakpoint_undo_stack[$depth] = $forced_breakpoint_undo_count;
+ $comma_index[$depth] = undef;
+ $last_comma_index[$depth] = undef;
+ $last_dot_index[$depth] = undef;
$old_breakpoint_count_stack[$depth] = $old_breakpoint_count;
$has_old_logical_breakpoints[$depth] = 0;
$rand_or_list[$depth] = [];
# and we made breakpoints between the opening and closing
&& ( $breakpoint_undo_stack[$current_depth] <
- get_forced_breakpoint_undo_count() )
+ $forced_breakpoint_undo_count )
# and this block is short enough to fit on one line
# Note: use < because need 1 more space for possible comma
# now see if we have any comma breakpoints left
my $has_comma_breakpoints =
( $breakpoint_stack[$current_depth] !=
- get_forced_breakpoint_count() );
+ $forced_breakpoint_count );
# update broken-sublist flag of the outer container
$has_broken_sublist[$depth] =
if (
$is_assignment{$next_nonblank_type}
&& ( $breakpoint_stack[$current_depth] !=
- get_forced_breakpoint_count() )
+ $forced_breakpoint_count )
)
{
$self->set_forced_breakpoint($i);
0 && do {
my ( $a, $b, $c ) = caller();
- my $forced_breakpoint_count = get_forced_breakpoint_count();
print STDOUT
"NOBREAK: forced_breakpoint $forced_breakpoint_count from $a $c with i=$i max=$max_index_to_go type=$types_to_go[$i]\n";
};