geen onnodige moves maken....
This commit is contained in:
parent
3aa5c14d17
commit
56472b9ea3
1 changed files with 8 additions and 3 deletions
|
|
@ -170,16 +170,21 @@ sub check_unique (@target_list){
|
||||||
# Returns an array of unsafe line numbers
|
# Returns an array of unsafe line numbers
|
||||||
sub check_safety {
|
sub check_safety {
|
||||||
my ($from, $to) = @_;
|
my ($from, $to) = @_;
|
||||||
my ($i, $j, @danger);
|
my ($i, $j, @danger, @unique, %seen);
|
||||||
|
my ($a, $b);
|
||||||
for ( $i=0 ; $i < scalar(@$from) ; $i++ ) {
|
for ( $i=0 ; $i < scalar(@$from) ; $i++ ) {
|
||||||
for ( $j=0; $j < scalar(@$to); $j++ ) {
|
for ( $j=0; $j < scalar(@$to); $j++ ) {
|
||||||
if ((chomp($from->[$i]) eq chomp($to->[$j])) && ($i != $j)) {
|
$a = $from->[$i]; chomp($a);
|
||||||
|
$b = $to->[$j]; chomp($b);
|
||||||
|
if (($a eq $b) && ($i != $j)) {
|
||||||
push @danger, $i;
|
push @danger, $i;
|
||||||
push @danger, $j;
|
push @danger, $j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return @danger;
|
%seen = ();
|
||||||
|
@unique = grep { ! $seen{$_} ++ } @danger;
|
||||||
|
return @unique;
|
||||||
}
|
}
|
||||||
|
|
||||||
# generate random filename, which does not exist
|
# generate random filename, which does not exist
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue