RFR: 2311: Use getLast and removeLast methods for lists

Pavel Rappo prappo at openjdk.org
Fri Jun 28 17:31:53 UTC 2024


Please review this simple refactoring to change most if not all occurrences of `list.get(x.size() - 1)` to `list.getLast()`.

`getLast` was introduced in JDK 21, as part of JEP 431: Sequenced Collections, which also introduced a counterpart method, `getFirst()`. While there are also a lot of occurrences of `list.get(0)` in Skara codebase, changing them to `list.getFirst()` might be of insufficient benefit and, hence, is not proposed in this PR. I don't think that coinciding `get(0)` and `getLast()` would look inconsistent.

The copyright years will be updated after this PR has been reviewed.

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

Commit messages:
 - Initial commit

Changes: https://git.openjdk.org/skara/pull/1665/files
  Webrev: https://webrevs.openjdk.org/?repo=skara&pr=1665&range=00
  Issue: https://bugs.openjdk.org/browse/SKARA-2311
  Stats: 51 lines in 22 files changed: 0 ins; 0 del; 51 mod
  Patch: https://git.openjdk.org/skara/pull/1665.diff
  Fetch: git fetch https://git.openjdk.org/skara.git pull/1665/head:pull/1665

PR: https://git.openjdk.org/skara/pull/1665


More information about the skara-dev mailing list