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 | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/GitACL.pm b/lib/GitACL.pm index f7743d5..4c1cc67 100644 --- a/lib/GitACL.pm +++ b/lib/GitACL.pm @@ -17,7 +17,6 @@ package GitACL; use strict; -use feature "state"; use File::Spec; use Net::CIDR qw (cidrlookup); @@ -166,34 +165,32 @@ sub match_ref($$) { 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", + $self->{tree} = [git_values("diff-tree", "--no-commit-id", "--name-only", "-r", - $self->{new}); + $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($$) { |