mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8283996: Reduce cost of year and month calculations
Reviewed-by: bpb, scolebourne, naoto, rriggs
This commit is contained in:
parent
45d4d7da23
commit
1a5f5da050
2 changed files with 11 additions and 6 deletions
|
@ -974,11 +974,11 @@ public final class ZoneRules implements Serializable {
|
|||
doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400);
|
||||
}
|
||||
yearEst += adjust; // reset any negative year
|
||||
int marchDoy0 = (int) doyEst;
|
||||
|
||||
// convert march-based values back to january-based
|
||||
int marchMonth0 = (marchDoy0 * 5 + 2) / 153;
|
||||
yearEst += marchMonth0 / 10;
|
||||
// convert march-based values back to january-based, adjust year
|
||||
if (doyEst >= 306) {
|
||||
yearEst++;
|
||||
}
|
||||
|
||||
// Cap to the max value
|
||||
return (int)Math.min(yearEst, Year.MAX_VALUE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue