2008-08-04 Jb Evain <jbevain@novell.com>
authorJb Evain <jbevain@gmail.com>
Mon, 4 Aug 2008 13:51:24 +0000 (13:51 -0000)
committerJb Evain <jbevain@gmail.com>
Mon, 4 Aug 2008 13:51:24 +0000 (13:51 -0000)
* TimeZoneInfo.cs: avoid using a SortedDictionary when not needed.

svn path=/trunk/mcs/; revision=109564

mcs/class/System.Core/System/ChangeLog
mcs/class/System.Core/System/TimeZoneInfo.cs

index c3b51e985755a56e5790e8c5d41555f1b4be0638..d750c99b08628cad039dc515ca53113e4662f7a0 100644 (file)
@@ -1,3 +1,7 @@
+2008-08-04  Jb Evain  <jbevain@novell.com>
+
+       * TimeZoneInfo.cs: avoid using a SortedDictionary when not needed.
+
 2008-06-25  Jb Evain  <jbevain@novell.com>
 
        * TimeZoneInfo.cs: remove the dependance to Mono.DataConverter
index 5c8c7358522a2d25eda571bf0928ea297fe081ed..573a246e6f5216d3f23942fe736c051176bd55da 100644 (file)
@@ -668,7 +668,7 @@ namespace System
 
                        Dictionary<int, string> abbreviations = ParseAbbreviations (buffer, 44 + 4 * timecnt + timecnt + 6 * typecnt, charcnt);
                        Dictionary<int, TimeType> time_types = ParseTimesTypes (buffer, 44 + 4 * timecnt + timecnt, typecnt, abbreviations);
-                       SortedList<DateTime, TimeType> transitions = ParseTransitions (buffer, 44, timecnt, time_types);
+                       List<KeyValuePair<DateTime, TimeType>> transitions = ParseTransitions (buffer, 44, timecnt, time_types);
 
                        if (time_types.Count == 0)
                                throw new InvalidTimeZoneException ();
@@ -685,8 +685,9 @@ namespace System
                        List<AdjustmentRule> adjustmentRules = new List<AdjustmentRule> ();
 
                        for (int i = 0; i < transitions.Count; i++) {
-                               DateTime ttime = transitions.Keys [i];
-                               TimeType ttype = transitions [ttime];
+                               var pair = transitions [i];
+                               DateTime ttime = pair.Key;
+                               TimeType ttype = pair.Value;
                                if (!ttype.IsDst) {
                                        if (standardDisplayName != ttype.Name || baseUtcOffset.TotalSeconds != ttype.Offset) {
                                                standardDisplayName = ttype.Name;
@@ -774,16 +775,16 @@ namespace System
                        return types;
                }
 
-               static SortedList<DateTime, TimeType> ParseTransitions (byte [] buffer, int index, int count, Dictionary<int, TimeType> time_types)
+               static List<KeyValuePair<DateTime, TimeType>> ParseTransitions (byte [] buffer, int index, int count, Dictionary<int, TimeType> time_types)
                {
-                       var trans = new SortedList<DateTime, TimeType> (count);
+                       var list = new List<KeyValuePair<DateTime, TimeType>> (count);
                        for (int i = 0; i < count; i++) {
                                int unixtime = ReadBigEndianInt32 (buffer, index + 4 * i);
                                DateTime ttime = DateTimeFromUnixTime (unixtime);
                                byte ttype = buffer [index + 4 * count + i];
-                               trans.Add (ttime, time_types [(int)ttype]);
+                               list.Add (new KeyValuePair<DateTime, TimeType> (ttime, time_types [(int)ttype]));
                        }
-                       return trans;
+                       return list;
                }
 
                static DateTime DateTimeFromUnixTime (long unix_time)