<i18n dev> RFR: 8271603: Unnecessary Vector usage in java.desktop
Sergey Bylokhov
serb at openjdk.java.net
Mon Aug 9 07:21:49 UTC 2021
On Sun, 4 Jul 2021 20:42:41 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:
> Usage of thread-safe collection `Vector` is unnecessary. It's recommended to use `ArrayList` if a thread-safe implementation is not needed. In post-BiasedLocking times, this is gets worse, as every access is synchronized.
> I checked only places where `Vector` was used as local variable.
src/java.desktop/share/classes/java/awt/MenuBar.java line 348:
> 346: Iterator<MenuShortcut> e = getMenu(i).shortcuts();
> 347: while (e.hasNext()) {
> 348: shortcuts.addElement(e.next());
I think it is fine to replace the Enumeration with the Iterator in most of the places, but here we will get a kind of mix of both, since we cannot remove the usage of Enumeration in the return time.
src/java.desktop/share/classes/javax/print/MimeType.java line 576:
> 574: ArrayList<String> thePieces = new ArrayList<>();
> 575: boolean mediaTypeIsText;
> 576: boolean parameterNameIsCharset;
Default values might be removed as a separate cleanup.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4680
More information about the i18n-dev
mailing list