<i18n dev> RFR: 8319423: Improve Year.isLeap by checking divisibility by 16

Lothar Kimmeringer job at kimmeringer.de
Wed Nov 8 12:38:42 UTC 2023



Am 03.11.2023 um 22:01 schrieb Claes Redestad:

>      public static boolean isLeap(long year) {
>          return (year & 15) == 0 ? (year & 3) == 0 : (year & 3) == 0 && year % 100 != 0;
>      }

Not sure if this has any effect in terms of performance but not being a
fan of duplicated code, a variant would be

   return (year & 3) == 0 && (year & 15 == 0 || year % 100 != 0);


Cheers, Lothar


More information about the i18n-dev mailing list