>>- Component#preferredSize is a cached value - why is it necessary to
>>cache this value? Is it expensive to retrieve?
>
> It can be.

I'll add that due to the nature of layout, a component might be asked
for its preferred size N times in one event loop as each component in
its ancestry lays itself out, so caching it especially optimizes this
case.  In my tests, caching this reduced layout time by almost two
orders of magnitude (from ~100ms to ~1ms).

Reply via email to