Some tweaks to optimize 16

This commit is contained in:
Tom Eastep 2011-11-25 10:42:10 -08:00
parent 0f02b497f6
commit 71bbd7963c

View File

@ -2847,14 +2847,10 @@ sub optimize_level8( $$$ ) {
sub get_dports( $ ) { sub get_dports( $ ) {
my $ruleref = shift; my $ruleref = shift;
return $ruleref->{dport} if $ruleref->{dport}; my $ports = $ruleref->{dport} || '';
my $multiref = $ruleref->{multiport};
return undef unless $multiref;
my $ports = '';
unless ( $ports ) {
if ( my $multiref = $ruleref->{multiport} ) {
if ( reftype $multiref ) { if ( reftype $multiref ) {
for ( @$multiref ) { for ( @$multiref ) {
$ports .= ",$1" if /^--dports (.*)/; $ports .= ",$1" if /^--dports (.*)/;
@ -2862,6 +2858,8 @@ sub get_dports( $ ) {
} else { } else {
$ports = $1 if $multiref =~ /^--dports (.*)/; $ports = $1 if $multiref =~ /^--dports (.*)/;
} }
}
}
$ports; $ports;
} }
@ -2870,10 +2868,9 @@ sub get_dports( $ ) {
# Returns a comma-separated list of multiport source ports from the passed rule # Returns a comma-separated list of multiport source ports from the passed rule
# #
sub get_multi_sports( $ ) { sub get_multi_sports( $ ) {
my $ruleref = shift;
my $ports = ''; my $ports = '';
if ( my $multiref = $ruleref->{multiport} ) { if ( my $multiref = $_[0]->{multiport} ) {
if ( reftype $multiref ) { if ( reftype $multiref ) {
for ( @$multiref ) { for ( @$multiref ) {
$ports .= ",$1" if /^--sports (.*)/; $ports .= ",$1" if /^--sports (.*)/;
@ -2887,7 +2884,7 @@ sub get_multi_sports( $ ) {
} }
# #
# The arguments are a list of rule references; returns a similar list with adjacent compatible rules combined # The arguments are a list of rule references; function returns a similar list with adjacent compatible rules combined
# #
# Adjacent rules are compatible if: # Adjacent rules are compatible if:
# #
@ -2899,8 +2896,9 @@ sub get_multi_sports( $ ) {
sub combine_dports { sub combine_dports {
my @rules; my @rules;
if ( my $baseref = shift ) { my $baseref = shift;
BASE:
while ( $baseref ) {
{ {
my $ruleref; my $ruleref;
my $ports1; my $ports1;
@ -2914,7 +2912,9 @@ sub combine_dports {
my $comment = $baseref->{comment} || ''; my $comment = $baseref->{comment} || '';
my $lastcomment = $comment; my $lastcomment = $comment;
my $sourceports = get_multi_sports( $baseref ); my $sourceports = get_multi_sports( $baseref );
RULE: RULE:
while ( ( $ruleref = shift ) && $ports < 15 ) { while ( ( $ruleref = shift ) && $ports < 15 ) {
my $ports2; my $ports2;
@ -2983,8 +2983,6 @@ sub combine_dports {
push @rules, $baseref; push @rules, $baseref;
$baseref = $ruleref ? $ruleref : shift; $baseref = $ruleref ? $ruleref : shift;
redo BASE if $baseref;
} }
} }