RFR: 8266571: Sequenced Collections
Viktor Klang
duke at openjdk.org
Mon Mar 20 23:45:04 UTC 2023
On Tue, 8 Feb 2022 17:23:38 GMT, Stuart Marks <smarks at openjdk.org> wrote:
> PR for Sequenced Collections implementation.
src/java.base/share/classes/java/util/LinkedHashMap.java line 384:
> 382: return this.put(k, v);
> 383: } finally {
> 384: putMode = PUT_NORM;
@stuart-marks Would it be an alternative to have an `internalPut(mode, k, v)` so there is no need to have an internal variable which needs to be read/written multiple time per operation? 🤔
src/java.base/share/classes/java/util/SequencedCollection.java line 93:
> 91: * underlying collection. Changes to the underlying collection might or might not be visible
> 92: * in this reversed view, depending upon the implementation.
> 93: *
@stuart-marks Perhaps an opportunity to spec it so that x == x.reversed().reversed() (i.e. unwrap on double-reverse)?
src/java.base/share/classes/java/util/SequencedCollection.java line 155:
> 153: */
> 154: default E getLast() {
> 155: return this.reversed().iterator().next();
@stuart-marks Are these default implementation expected to be used (actually) in the JDK? From a performance PoV, it might make sense to not have default implementations unless strictly needed, and instead keep the code in the JavaDoc as a guideline for "worst-case" performance profile. 🤔
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r987925904
PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r986962055
PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r987216743
More information about the core-libs-dev
mailing list