mirror of
https://gitlab.com/shorewall/code.git
synced 2024-11-26 09:33:14 +01:00
Speed up delete_jumps()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
91a711b34f
commit
715ea9ef32
@ -673,23 +673,24 @@ sub add_jump( $$$;$$$ ) {
|
||||
#
|
||||
sub delete_jumps ( $$ ) {
|
||||
my ( $fromref, $toref ) = @_;
|
||||
my $to = $toref->{name};
|
||||
my $last = 0;
|
||||
my $rule;
|
||||
my $to = $toref->{name};
|
||||
my $from = $fromref->{name};
|
||||
my $rules = $fromref->{rules};
|
||||
my $refs = $toref->{references}{$from};
|
||||
#
|
||||
# A C-style for-loop with indexing seems to work best here, given that we are
|
||||
# deleting elements from the array over which we are iterating.
|
||||
#
|
||||
for ( $rule = 0; $rule <= $#{$fromref->{rules}}; $rule++ ) {
|
||||
if ( $fromref->{rules}[$rule] =~ / -[gj] ${to}\b/ ) {
|
||||
for ( my $rule = 0; $rule <= $#{$rules}; $rule++ ) {
|
||||
if ( $rules->[$rule] =~ / -[gj] ${to}\b/ ) {
|
||||
trace( $fromref, 'D', $rule + 1, $_ ) if $debug;
|
||||
splice( @{$fromref->{rules}}, $rule, 1 );
|
||||
last unless --$toref->{references}{$fromref->{name}} > 0;
|
||||
splice( @$rules, $rule, 1 );
|
||||
last unless --$refs > 0;
|
||||
$rule--;
|
||||
}
|
||||
}
|
||||
|
||||
delete $toref->{references}{$fromref->{name}};
|
||||
delete $toref->{references}{$from};
|
||||
|
||||
unless ( @{$toref->{rules}} ) {
|
||||
$toref->{referenced} = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user