RFR: 8319423: Improve Year.isLeap by checking divisibility by 16
Claes Redestad
redestad at openjdk.org
Fri Nov 3 23:37:14 UTC 2023
On Fri, 3 Nov 2023 22:37:40 GMT, Andriy Plokhotnyuk <duke at openjdk.org> wrote:
> @cl4es Could you please test [this](https://github.com/plokhotnyuk/jsoniter-scala/blob/ba6f4f80deaf0e7a1a95787321de3cc2a232d66d/jsoniter-scala-core/jvm/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReader.scala#L3687) function too? It seems that when testing divisibility by 100 we can use just one multiplication operation.
For int values it seems that makes it a few percent faster (1,061 ± 0,017 ops/us), though we need a variant that works for longs (`GregorianCalendar` could use this as-is, but not `Year`). Do you have a reference to how they arrived at these numbers? It might be straightforward to extend it to long values, and it'd be good to have the theory to reference either way.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16491#issuecomment-1793241302
More information about the core-libs-dev
mailing list