6560981: (cal) unused local variables in GregorianCalendar, etc.

Reviewed-by: naoto, bchristi, iris
This commit is contained in:
Justin Lu 2022-10-06 23:16:06 +00:00 committed by Naoto Sato
parent 5dd851d872
commit d4c9a88073
3 changed files with 3 additions and 9 deletions

View File

@ -2431,7 +2431,6 @@ public class GregorianCalendar extends Calendar {
long fixedDateJan1 = calsys.getFixedDate(normalizedYear, 1, 1, cdate); long fixedDateJan1 = calsys.getFixedDate(normalizedYear, 1, 1, cdate);
int dayOfYear = (int)(fixedDate - fixedDateJan1) + 1; int dayOfYear = (int)(fixedDate - fixedDateJan1) + 1;
long fixedDateMonth1 = fixedDate - dayOfMonth + 1; long fixedDateMonth1 = fixedDate - dayOfMonth + 1;
int cutoverGap = 0;
int cutoverYear = (calsys == gcal) ? gregorianCutoverYear : gregorianCutoverYearJulian; int cutoverYear = (calsys == gcal) ? gregorianCutoverYear : gregorianCutoverYearJulian;
int relativeDayOfMonth = dayOfMonth - 1; int relativeDayOfMonth = dayOfMonth - 1;
@ -2447,9 +2446,7 @@ public class GregorianCalendar extends Calendar {
fixedDateMonth1 = getFixedDateMonth1(cdate, fixedDate); fixedDateMonth1 = getFixedDateMonth1(cdate, fixedDate);
} }
} }
int realDayOfYear = (int)(fixedDate - fixedDateJan1) + 1; dayOfYear = (int)(fixedDate - fixedDateJan1) + 1;
cutoverGap = dayOfYear - realDayOfYear;
dayOfYear = realDayOfYear;
relativeDayOfMonth = (int)(fixedDate - fixedDateMonth1); relativeDayOfMonth = (int)(fixedDate - fixedDateMonth1);
} }
internalSet(DAY_OF_YEAR, dayOfYear); internalSet(DAY_OF_YEAR, dayOfYear);

View File

@ -2118,7 +2118,6 @@ class JapaneseImperialCalendar extends Calendar {
* @param fixedDate the fixed date representation of the date * @param fixedDate the fixed date representation of the date
*/ */
private long getFixedDateJan1(LocalGregorianCalendar.Date date, long fixedDate) { private long getFixedDateJan1(LocalGregorianCalendar.Date date, long fixedDate) {
Era era = date.getEra();
if (date.getEra() != null && date.getYear() == 1) { if (date.getEra() != null && date.getYear() == 1) {
for (int eraIndex = getEraIndex(date); eraIndex > 0; eraIndex--) { for (int eraIndex = getEraIndex(date); eraIndex > 0; eraIndex--) {
CalendarDate d = eras[eraIndex].getSinceDate(); CalendarDate d = eras[eraIndex].getSinceDate();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -494,7 +494,7 @@ public abstract class BaseCalendar extends AbstractCalendar {
*/ */
final int getGregorianYearFromFixedDate(long fixedDate) { final int getGregorianYearFromFixedDate(long fixedDate) {
long d0; long d0;
int d1, d2, d3, d4; int d1, d2, d3;
int n400, n100, n4, n1; int n400, n100, n4, n1;
int year; int year;
@ -507,7 +507,6 @@ public abstract class BaseCalendar extends AbstractCalendar {
n4 = d2 / 1461; n4 = d2 / 1461;
d3 = d2 % 1461; d3 = d2 % 1461;
n1 = d3 / 365; n1 = d3 / 365;
d4 = (d3 % 365) + 1;
} else { } else {
d0 = fixedDate - 1; d0 = fixedDate - 1;
n400 = (int)CalendarUtils.floorDivide(d0, 146097L); n400 = (int)CalendarUtils.floorDivide(d0, 146097L);
@ -517,7 +516,6 @@ public abstract class BaseCalendar extends AbstractCalendar {
n4 = CalendarUtils.floorDivide(d2, 1461); n4 = CalendarUtils.floorDivide(d2, 1461);
d3 = CalendarUtils.mod(d2, 1461); d3 = CalendarUtils.mod(d2, 1461);
n1 = CalendarUtils.floorDivide(d3, 365); n1 = CalendarUtils.floorDivide(d3, 365);
d4 = CalendarUtils.mod(d3, 365) + 1;
} }
year = 400 * n400 + 100 * n100 + 4 * n4 + n1; year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
if (!(n100 == 4 || n1 == 4)) { if (!(n100 == 4 || n1 == 4)) {