diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2009-03-01 17:09:07 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2009-03-01 17:09:07 +0100 |
commit | e2469e37488fe46257f1f4f4f8b0ebe11c08da47 (patch) | |
tree | fa0838d9eb795cfc6b154b7f014d85f597ab5741 /pidl/lib/Parse | |
parent | 54bc27e9374742d37b1ed9012d1cfe8f5ace6d40 (diff) | |
download | samba-e2469e37488fe46257f1f4f4f8b0ebe11c08da47.tar.gz samba-e2469e37488fe46257f1f4f4f8b0ebe11c08da47.tar.bz2 samba-e2469e37488fe46257f1f4f4f8b0ebe11c08da47.zip |
Don't generate array iterators when the length of the array is always 0.
(bug #6140)
Diffstat (limited to 'pidl/lib/Parse')
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 0e4a7e2289..34aebc7f0f 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -586,9 +586,15 @@ sub ParseElementPushLevel my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL}); my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; + my $array_pointless = ($length eq "0"); + + if ($array_pointless) { + warning($e->{ORIGINAL}, "pointless array `$e->{NAME}' will always have size 0"); + } + $var_name = get_array_element($var_name, $counter); - if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) { + if ((($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) and not $array_pointless) { $self->pidl("for ($counter = 0; $counter < $length; $counter++) {"); $self->indent; $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 0); @@ -596,7 +602,7 @@ sub ParseElementPushLevel $self->pidl("}"); } - if ($deferred and ContainsDeferred($e, $l)) { + if ($deferred and ContainsDeferred($e, $l) and not $array_pointless) { $self->pidl("for ($counter = 0; $counter < $length; $counter++) {"); $self->indent; $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 0, 1); |