1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

Don't generate array iterators when the length of the array is always 0.

(bug #6140)
This commit is contained in:
Jelmer Vernooij 2009-03-01 17:09:07 +01:00
parent 54bc27e937
commit e2469e3748

View File

@ -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);