8283996: Reduce cost of year and month calculations

Reviewed-by: bpb, scolebourne, naoto, rriggs
This commit is contained in:
Claes Redestad 2022-03-31 08:45:06 +00:00
parent 45d4d7da23
commit 1a5f5da050
2 changed files with 11 additions and 6 deletions

View file

@ -363,9 +363,14 @@ public final class LocalDate
// convert march-based values back to january-based
int marchMonth0 = (marchDoy0 * 5 + 2) / 153;
int month = (marchMonth0 + 2) % 12 + 1;
int month = marchMonth0 + 3;
if (month > 12) {
month -= 12;
}
int dom = marchDoy0 - (marchMonth0 * 306 + 5) / 10 + 1;
yearEst += marchMonth0 / 10;
if (marchDoy0 >= 306) {
yearEst++;
}
return new LocalDate((int)yearEst, month, dom);
}