[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: [OpenJDK 2D-Dev] RFR: 8271603: Unnecessary Vector usage in java.desktop [v4]
From:       Sergey Bylokhov <serb () openjdk ! java ! net>
Date:       2021-08-27 18:32:28
Message-ID: ZHTxa3hHOYqNUlSS9IoQJOqWbNpGr1KJ003JqowjDoc=.588a6b2c-2b9f-4aaf-8172-447c0ac16f43 () github ! com
[Download RAW message or body]

On Fri, 27 Aug 2021 17:52:19 GMT, Andrey Turbanov \
<github.com+741251+turbanoff@openjdk.org> wrote:

> > src/java.desktop/share/classes/javax/swing/JMenu.java line 1340:
> > 
> > > 1338:         }
> > > 1339:         MenuElement[] me = new MenuElement[elements.size()];
> > > 1340:         elements.toArray(me);
> > 
> > Implementation of the "toArray([])" is not equivalent of "copyInto([])". Maybe \
> > no-arg "return elements.toArray()" will look better. Same comment about other \
> > removed usage of copyInto
> 
> Can you please elaborate?
> As I can see if size of array is exactly the same as size of vector/arraylist, \
>                 implementations are similar - they just call System.arraycopy
> ![изображение](https://user-images.githubusercontent.com/741251/131168809-480c05d6-2775-4812-91f5-c73833f9a396.png)
> 

To confirm this you need to do the same check on every usage of added toArray([]), \
the simpler version like "return toArray()" or return toArray(new \
MenuElement[elements.size()]) is simpler, no need to check something. I guess in some \
previouse fixes it was confirmed that the "return toArray(new MenuElement[0])" is \
even faster.

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

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic