Author: miguel
Date: 2006-11-22 20:22:58 -0500 (Wed, 22 Nov 2006)
New Revision: 68379
Modified:
trunk/mcs/class/corlib/System/ChangeLog
trunk/mcs/class/corlib/System/DateTime.cs
Log:
2006-11-22 Miguel de Icaza <[EMAIL PROTECTED]>
* DateTime.cs: A small performance hit, we store the actual time
span in a boxed object. This way, it can be updated from other
threads if necessary. We always unbox to get the value before
any potential updates.
Thanks to Gonzalo for catching this.
Modified: trunk/mcs/class/corlib/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System/ChangeLog 2006-11-23 00:39:10 UTC (rev
68378)
+++ trunk/mcs/class/corlib/System/ChangeLog 2006-11-23 01:22:58 UTC (rev
68379)
@@ -1,3 +1,12 @@
+2006-11-22 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * DateTime.cs: A small performance hit, we store the actual time
+ span in a boxed object. This way, it can be updated from other
+ threads if necessary. We always unbox to get the value before
+ any potential updates.
+
+ Thanks to Gonzalo for catching this.
+
2006-11-21 Miguel de Icaza <[EMAIL PROTECTED]>
* TimeZone.cs (CurrentSystemTimeZone): Cache the current year
Modified: trunk/mcs/class/corlib/System/DateTime.cs
===================================================================
--- trunk/mcs/class/corlib/System/DateTime.cs 2006-11-23 00:39:10 UTC (rev
68378)
+++ trunk/mcs/class/corlib/System/DateTime.cs 2006-11-23 01:22:58 UTC (rev
68379)
@@ -423,7 +423,7 @@
// time into `to_local_time_span', we record the timestamp
// for this in `last_now'
//
- static TimeSpan to_local_time_span;
+ static object to_local_time_span_object;
static long last_now;
public static DateTime Now
@@ -434,11 +434,13 @@
DateTime dt = new DateTime (now);
if ((now - last_now) > TimeSpan.TicksPerMinute){
- to_local_time_span =
TimeZone.CurrentTimeZone.GetLocalTimeDiff (dt);
+ to_local_time_span_object =
TimeZone.CurrentTimeZone.GetLocalTimeDiff (dt);
last_now = now;
}
- return dt + to_local_time_span;
+
+ // This is boxed, so we avoid locking.
+ return dt + (TimeSpan)
to_local_time_span_object;
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches