On Fri, 20 Dec 2024 20:25:28 GMT, Roger Riggs <rri...@openjdk.org> wrote:
>> Naoto Sato has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Update src/java.base/share/classes/java/time/ZoneOffset.java >> >> Co-authored-by: Roger Riggs <roger.ri...@oracle.com> > > src/java.base/share/classes/java/time/ZoneOffset.java line 432: > >> 430: result = new ZoneOffset(totalSeconds); >> 431: SECONDS_CACHE.putIfAbsent(totalSecs, result); >> 432: result = SECONDS_CACHE.get(totalSecs); > > putIfAbsent() returns the existing value (if any), the 2nd get can be avoided > by using the non-null value if returned or returning the result just created. > Suggestion: > > var existing = SECONDS_CACHE.putIfAbsent(totalSecs, result); > return (existing != null) ? existing : result; > > It should perform better than doing the `get` again. That's right. Committed as suggested ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22854#discussion_r1894382433