struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Leland <Rob...@free2create.org>
Subject Re: PATCH: taglib/form/OptionsTag - Map support
Date Wed, 15 Nov 2000 12:30:58 GMT
Currently, the patch allows the mixing of Map and non Map entries
since the if statement is inside the while. Is that what you intended ?

Pulling the if outside the while would make the type checking 'instanceof'
a one time overhead, instead of for each iteration. 

-Rob
>         while (valuesIterator.hasNext()) {
> -           String value = (String) valuesIterator.next();
> -           String label = value;
> -           if (labelsIterator.hasNext())
> -               label = (String) labelsIterator.next();
> +
> +            Object next = valuesIterator.next();
> +
> +            String label, value;
> +            if ( next instanceof Map.Entry ) {
> +                Map.Entry entry = (Map.Entry) next;
> +                value = (String) entry.getKey();
> +                label = (String) entry.getValue();
> +            } else {
> +               value = (String) next;
> +               label = value;
> +               if (labelsIterator.hasNext())
> +                   label = (String) labelsIterator.next();
> +            }

-- 
Robert Leland			Robert@free2create.org
804 N. Kenmore Street		+01-703-525-3580
Arlington VA 22201

Mime
View raw message