<i18n dev> RFR: 8263561: Re-examine uses of LinkedList

liach github.com+7806504+liach at openjdk.java.net
Sun Mar 14 17:10:24 UTC 2021

On Sun, 14 Mar 2021 14:58:11 GMT, Yi Yang <yyang at openjdk.org> wrote:

>> The usage of `LinkedList` is senseless and can be replaced with either `ArrayList` or `ArrayDeque` which are both more compact and effective.
>> jdk:tier1 and jdk:tier2 are both ok
> src/java.base/share/classes/jdk/internal/loader/URLClassPath.java line 220:
>> 218:             return Collections.emptyList();
>> 219:         }
>> 220:         List<IOException> result = new ArrayList<>();
> We'd better be cautious about this replacement since its [caller](https://github.com/openjdk/jdk/blob/73029fe10a8a814a8c5f5221f2e667fd14a5b379/src/java.base/share/classes/java/net/URLClassLoader.java#L363) will remove the first element of this array, that's one of the scenarios where LinkedList usually has better performance than ArrayList.
> Just IMHO, I suggest replacing them only if there is a performance improvement(e.g. benchmark reports). Changing field types will break users' existing application code, they might reflectively modify these values.

If that's the only use case, I recommend changing the return type to a deque, and replace the linked list with an array deque instead (as done elsewhere in this pr)


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

More information about the i18n-dev mailing list