Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2006-11-23 04:22:58 +0300
committerMiguel de Icaza <miguel@gnome.org>2006-11-23 04:22:58 +0300
commit37972c64f1002d5c8bbd916fef3348aa53b0d610 (patch)
tree119ed1d817f0def597bc08c9826d5bd28a5d3b8e /mcs/class/corlib/System/DateTime.cs
parent256a3d04433f33d151ee2ef1fece0bc1a98a76c4 (diff)
2006-11-22 Miguel de Icaza <miguel@novell.com>
* 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. svn path=/trunk/mcs/; revision=68379
Diffstat (limited to 'mcs/class/corlib/System/DateTime.cs')
-rw-r--r--mcs/class/corlib/System/DateTime.cs8
1 files changed, 5 insertions, 3 deletions
diff --git a/mcs/class/corlib/System/DateTime.cs b/mcs/class/corlib/System/DateTime.cs
index 6b55b58c687..3579ce88386 100644
--- a/mcs/class/corlib/System/DateTime.cs
+++ b/mcs/class/corlib/System/DateTime.cs
@@ -423,7 +423,7 @@ namespace System
// 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 @@ namespace System
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;
}
}