Jim, > Ah, wait, those constructors do copy the arrays without having to iterate the segments and grow the arrays, but they don't trim them. I'm trying to remember if there was a specific reason that we decided not to trim the arrays in those constructors, but the only "advantage" I can think of is that the new copy will have the same potential spare room for growth that the original had. But that is of questionable value so we should probably just patch the existing "construct from a Shape" constructors to trim the arrays to the required length instead...
In marlin github, I have the patched Path2D class (not used at runtime): public Float(Shape s, AffineTransform at) { super(); // LBO: invoke empty constructor explicitely ! if (s instanceof Path2D) { Path2D p2d = (Path2D) s; setWindingRule(p2d.windingRule); this.numTypes = p2d.numTypes; // LBO: trim arrays: this.pointTypes = Arrays.copyOf(p2d.pointTypes, this.numTypes); // this.pointTypes = Arrays.copyOf(p2d.pointTypes, // p2d.pointTypes.length); this.numCoords = p2d.numCoords; this.floatCoords = p2d.cloneCoordsFloat(at); } else { PathIterator pi = s.getPathIterator(at); setWindingRule(pi.getWindingRule()); this.pointTypes = new byte[INIT_SIZE]; this.floatCoords = new float[INIT_SIZE * 2]; append(pi, false); } } float[] cloneCoordsFloat(AffineTransform at) { float ret[]; if (at == null) { // LBO: trim arrays: ret = Arrays.copyOf(floatCoords, numCoords); // ret = Arrays.copyOf(this.floatCoords, this.floatCoords.length); } else { // LBO: trim arrays: ret = new float[numCoords]; // ret = new float[floatCoords.length]; at.transform(floatCoords, 0, ret, 0, numCoords / 2); } return ret; } What do you think? FYI my use case in createStrokedShape () is to allocate (and reuse) a path2d (4k arrays), fill it and then return a new path whose arrays are trimmed. Laurent