On Fri, 25 Mar 2022 15:17:02 GMT, Stephen Colebourne <scolebou...@openjdk.org> 
wrote:

>> Claes Redestad has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Add nanoOfSecond parameter, make micro less reliant on constants
>
> src/java.base/share/classes/java/time/ZoneOffset.java line 512:
> 
>> 510:     @Override
>> 511:     /* package-private */ ZoneOffset getOffset(long epochSecond, int 
>> nanoOfSecond) {
>> 512:         return this;
> 
> An alternate approach would be for `ZoneOffset` to cache the instance of 
> `ZoneRules` either on construction or first use (racy idiom would be OK). 
> That way this issue is solved for the many different places that call 
> `zoneId.getRules()`.

Why not both? I measured an improvement using that alone, but specifically 
avoiding going via getRules is faster still (without adversely affecting 
`ZoneRegion` paths). I've added the cache in `ZoneOffset`, along with an 
override of `ZoneId::normalized` in `ZoneOffset` to shortcut the `getRules`.

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

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

Reply via email to