diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-07-31 00:31:28 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-07-31 00:31:28 +0300 |
commit | d45c8b4133e882b3d37ef63930849d714a517010 (patch) | |
tree | 786a5814a9a8fa81cf839a4859bdbe7431f81e3d | |
parent | 6c604cdf5bb45a6a3d58f1f2eb985622ed39248a (diff) | |
download | gitaclhook-d45c8b4133e882b3d37ef63930849d714a517010.tar.gz gitaclhook-d45c8b4133e882b3d37ef63930849d714a517010.tar.bz2 |
Minor imorivement
* lib/GitACL.pm: Use class attributes instead of state variables.
-rw-r--r-- | lib/GitACL.pm | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/GitACL.pm b/lib/GitACL.pm index f7743d5..4c1cc67 100644 --- a/lib/GitACL.pm +++ b/lib/GitACL.pm @@ -14,13 +14,12 @@ # You should have received a copy of the GNU General Public License # along with gitaclhook. If not, see <http://www.gnu.org/licenses/>. package GitACL; use strict; -use feature "state"; use File::Spec; use Net::CIDR qw (cidrlookup); my %opstr = ('C' => 'create', 'D' => 'delete', 'U' => 'update', @@ -163,40 +162,38 @@ sub match_ref($$) { if ($expr =~ /\/$/); return $self->{ref} eq $expr; } sub match_tree($$) { my ($self, $expr) = @_; - state @tree; - state $init; - unless (defined($init)) { + unless (defined($self->{tree_init})) { if (defined($self->{files})) { - @tree = @{$self->{files}}; + $self->{tree} = $self->{files}; } else { - @tree = git_values("diff-tree", - "--no-commit-id", "--name-only", "-r", - $self->{new}); + $self->{tree} = [git_values("diff-tree", + "--no-commit-id", "--name-only", "-r", + $self->{new})]; } - $init = 1; + $self->{tree_init} = 1; } - for (my $i = 0; $i <= $#tree; ) { - my $dir = $tree[$i]; + for (my $i = 0; $i <= $#{$self->{tree}}; ) { + my $dir = $self->{tree}[$i]; if (($expr =~ /^\^/ and $dir =~ /$expr/) or ($expr =~ /\/$/ and ("$dir/" eq $expr or index($dir, $expr) == 0)) or $dir eq $expr) { - splice(@tree, $i, 1); + splice(@{$self->{tree}}, $i, 1); } else { ++$i; } } - return $#tree == -1; + return $#{$self->{tree}} == -1; } sub match_tuple($$) { my ($self, $tuple) = @_; my @x = @{$tuple}; |