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