pidl/NDR/Parser: simplify logic in DeclareArrayVariables*()
authorStefan Metzmacher <metze@samba.org>
Thu, 15 Mar 2012 12:12:04 +0000 (13:12 +0100)
committerKarolin Seeger <kseeger@samba.org>
Sat, 7 Apr 2012 14:26:03 +0000 (16:26 +0200)
metze

pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm

index ccf9af97f35707ef1ed768106451593838aedc85..31250014c39f96d17d4eb6b65d1d9477886ef4ad 100644 (file)
@@ -1512,11 +1512,10 @@ sub DeclareArrayVariables($$)
        my ($self,$e) = @_;
 
        foreach my $l (@{$e->{LEVELS}}) {
+               next if ($l->{TYPE} ne "ARRAY");
                next if has_fast_array($e,$l);
                next if is_charset_array($e,$l);
-               if ($l->{TYPE} eq "ARRAY") {
-                       $self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
-               }
+               $self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
        }
 }
 
@@ -1525,15 +1524,14 @@ sub DeclareArrayVariablesNoZero($$$)
        my ($self,$e,$env) = @_;
 
        foreach my $l (@{$e->{LEVELS}}) {
+               next if ($l->{TYPE} ne "ARRAY");
                next if has_fast_array($e,$l);
                next if is_charset_array($e,$l);
-               if ($l->{TYPE} eq "ARRAY") {
-                   my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
-                   if ($length eq "0") {
+               my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
+               if ($length eq "0") {
                        warning($e->{ORIGINAL}, "pointless array cntr: 'cntr_$e->{NAME}_$l->{LEVEL_INDEX}': length=$length");
-                   } else {
+               } else {
                        $self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
-                   }
                }
        }
 }