Request for new issue in bug tracker: Unnecessary arrays in TextLine

Daniel Gredler djgredler at gmail.com
Fri Nov 8 15:56:04 UTC 2024


Hi all,

During recent debugging looking at JDK-8148334 [1], I ran across
`TextLine.createComponentsOnRun(...)`, which seems to be a bit too eager to
expand the component array, leading to the following steps:

1. `TextLine.fastCreateTextLine(...)` allocates a one-element component
array, passing it to `createComponentsOnRun(...)`
2. `createComponentsOnRun(...)` adds a single element to the array, but
expands the array (i.e. creates a new larger array) to fit more
(non-existent) elements, returning the larger array
3. `TextLine.fastCreateTextLine(...)` detects the larger-than-necessary
array, and trims it back down to size (i.e. creates a new smaller array)

The fix is simple: check if `numComponents > components.length` before
expanding the array, instead of the current check of `numComponents >=
components.length`.

Could somebody file a bug in the issue tracker, so that I can submit a PR
to fix this? I do not have access to create issues.

Thanks!

Daniel

[1] https://bugs.openjdk.org/browse/JDK-8148334
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/client-libs-dev/attachments/20241108/d875346e/attachment.htm>


More information about the client-libs-dev mailing list