RFR: 8273684: Unnecessary Stack usage

Andrey Turbanov github.com+741251+turbanoff at openjdk.java.net
Mon Sep 13 19:29:29 UTC 2021


On Wed, 8 Sep 2021 21:34:06 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> Usage of thread-safe collection Stack is unnecessary. It's recommended to use ArrayDequeue if a thread-safe implementation is not needed.
>
> src/java.desktop/share/classes/com/sun/media/sound/DLSSoundbank.java line 34:
> 
>> 32: import java.io.OutputStream;
>> 33: import java.net.URL;
>> 34: import java.util.ArrayDeque;
> 
> Can we remove the Stack from the list of imports?

Removed

> src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java line 2719:
> 
>> 2717:             }
>> 2718:             Element[] retValue = new Element[elements.size()];
>> 2719:             elements.toArray(retValue);
> 
> Same comment as in some other review, the copyInto and toArray works differently, it is better to use return elements.toArray(new Element[0]);

Updated

-------------

PR: https://git.openjdk.java.net/jdk/pull/5294


More information about the serviceability-dev mailing list