classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] FYI: Fix for BoxLayout


From: Roman Kennke
Subject: Re: [cp-patches] FYI: Fix for BoxLayout
Date: Tue, 28 Jun 2005 21:57:43 +0200

Am Montag, den 27.06.2005, 11:08 -0600 schrieb Tom Tromey:
> >>>>> "Roman" == Roman Kennke <address@hidden> writes:
> 
> Roman> +  public static Component[] getVisibleChildren(Container c)
> Roman> +  {
> Roman> +    Component[] children = c.getComponents();
> Roman> +    Vector visible = new Vector();
> Roman> +    for (int i = 0; i < children.length; i++)
> Roman> +      if (children[i].isVisible())
> Roman> +        visible.add(children[i]);
> Roman> +    return (Component[]) visible.toArray(new 
> Container[visible.size()]);
> 
> This means multiple allocations per layout.

I could easily optimize this. I would have to return an implementation
of Collection (or List, for correctness of semantics) that wraps the
Component[] returned by getComponents() and provides an Iterator over
this. This could still mean 2 allocations per layout (one for the List,
one for the collection), but both could probably be cached for later
use.

Do you think this is preferable? Or should the LayoutManagers sort this
out on themselves?

/Roman






reply via email to

[Prev in Thread] Current Thread [Next in Thread]