-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.0
-
generic
-
generic
Name: stC104175 Date: 03/31/2000
java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)
The following code exists at the bottom of the GregorianCalendar.add method. In
spite of the comment, the extra call to setTimeInMillis is done every time,
slowing down date math. The last if statement should compare dst (rather than
delta) to zero.
This bug goes back to at least version 1.2.
// Save the current DST state.
long dst = 0;
if (adjustDST) dst = internalGet(DST_OFFSET);
setTimeInMillis(time + delta); // Automatically computes
fields if necessary
if (adjustDST) {
// Now do the DST adjustment alluded to above.
// Only call setTimeInMillis if necessary,
because it's an expensive call.
dst -= internalGet(DST_OFFSET);
if (delta != 0) setTimeInMillis(time + dst);
}
(Review ID: 103093)
======================================================================
- duplicates
-
JDK-4302563 GregorianCalendor.add(int, int) wrong optimisation
-
- Resolved
-