On Fri, Apr 11, 2025 at 10:50 AM Engebretson, John <jeng...@amazon.com> wrote:
> I would like to see JDK standard "array builders" for primitive types and > reference types that use fixed sized (power-of-two) segments internally. > > > > I want to caution on the power-of-two idea – it leads to large objects > faster than the current implementation, which hurts performance as well as > max capacity. There is value in fixed-size options but we would want > something with a slower rate of growth. > Sorry if that wasn't clear - I didn't mean power-of-two exponential growth, I meant all segments were literally fixed size, like 256 or something (or maybe this value would be provided to the constructor). This keeps the access to individual elements constant time. > > > The "underlying problem" that I think should be addressed by some new > internal class (or suite of classes) is the "array builder" problem. This > is where you're doing "append, append, append, ..., use read-only > thereafter". > > > > I would prefer targeting a few, common use cases – ByteArrayOutputStream > is the example that got us here. Optimizing forward-only handling is an > easy starting place and we can always add on later. > Fair enough - my idea is independent in the sense that it could be done later and then retrofitted. So I think I should probably go off and think about it more and stop hijacking your thread :) -Archie -- Archie L. Cobbs