From: Steve Hancock Date: Sat, 16 Jul 2022 17:50:42 +0000 (-0700) Subject: switch storage from array to hash X-Git-Tag: 20220613.03~16 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ff00e84a1d729f2784d4fcad71683c1b0d7b629b;p=perltidy.git switch storage from array to hash --- diff --git a/lib/Perl/Tidy/VerticalAligner/Alignment.pm b/lib/Perl/Tidy/VerticalAligner/Alignment.pm index 554aa16e..972249ad 100644 --- a/lib/Perl/Tidy/VerticalAligner/Alignment.pm +++ b/lib/Perl/Tidy/VerticalAligner/Alignment.pm @@ -12,24 +12,9 @@ use warnings; our $VERSION = '20220613.02'; -BEGIN { - - # Indexes for variables in $self. - # Do not combine with other BEGIN blocks (c101). - # _column_ # the current column number - # _saved_column_ # a place for temporary storage - my $i = 0; - use constant { - _column_ => $i++, - _saved_column_ => $i++, - }; -} - sub new { my ( $class, $rarg ) = @_; - my $self = bless [], $class; - $self->[_column_] = $rarg->{column}; - $self->[_saved_column_] = $rarg->{saved_column}; + my $self = bless $rarg, $class; return $self; } @@ -60,23 +45,23 @@ sub DESTROY { } sub get_column { - return $_[0]->[_column_]; + return $_[0]->{'column'}; } sub increment_column { - $_[0]->[_column_] += $_[1]; + $_[0]->{'column'} += $_[1]; + return; } sub save_column { - $_[0]->[_saved_column_] = $_[0]->[_column_]; + $_[0]->{'saved_column'} = $_[0]->{'column'}; return; } sub restore_column { - $_[0]->[_column_] = $_[0]->[_saved_column_]; + $_[0]->{'column'} = $_[0]->{'saved_column'}; return; } } ## end of package VerticalAligner::Alignment 1; -