From: Gavin_King/Cirrus%<CI...@ci...> - 2002-08-22 08:21:37
|
>if we had to copy them each time we took a >snapshot then we would also need to create two new java.util.Calendars each >time we compared them (rather than using ==). I realise this sounds really bad.... Actually the code to compare dates/times looks something like: if (x==y) return true; Calendar c1 = Calendar.getInstance(); Calendar c12 = Calendar.getInstance(); c1.setTime(x); c2.setTime(y); ........ So what I meant was: if you treat them as immutable + so don't take a copy when you capture the snapshot state, you get a shortcut exit from that section of code before you create the Calendars. Now if only the stupid Calendar class would allow threadsafe usage eg: calendar.get(Calendar.DAY, date) then this wouldn't be an issue..... |