On Fri, 24 Mar 2023 22:06:06 GMT, Tagir F. Valeev <tval...@openjdk.org> wrote:

>> Stuart Marks has updated the pull request with a new target base due to a 
>> merge or a rebase. The pull request now contains 96 commits:
>> 
>>  - Merge branch 'master' into JDK-8266571-SequencedCollections
>>  - Optimizations for ReverseOrderListView; check indexes in reversed domain.
>>  - Wording tweaks to SequencedMap / NavigableMap.
>>  - Change "The implementation in this class" to "... interface."
>>  - Delegate more methods in the views of ReverseOrderSortedMapView.
>>  - Add missing @throws and @since tags.
>>  - Convert code samples to snippets.
>>  - Various editorial changes.
>>  - Fix up toArray(T[]) on reverse-ordered views.
>>  - Remove unnecessary 'final' from a couple places.
>>  - ... and 86 more: https://git.openjdk.org/jdk/compare/2ea62c13...2827aa69
>
> src/java.base/share/classes/java/util/ReverseOrderListView.java line 168:
> 
>> 166:         boolean modified = false;
>> 167:         for (E e : c) {
>> 168:             base.add(0, e);
> 
> This is worrysome from performance point of view for base implementations 
> like ArrayList where every insertion means shifting the whole array. At 
> least, we could optimize if `c` is `SequencedCollection`, like `if (c 
> instanceof SequencedCollection<? extends E> sc) base.addAll(0, 
> sc.reversed())`. Otherwise, we can use `base.addAll(0, 
> Arrays.asList(sc.toArray()).reversed())` (with a couple of unchecked casts).

Fixed.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1175897522

Reply via email to