소스 검색

2009-07-20 Jb Evain <[email protected]>

	* Lookup.cs: avoid a double dictionary lookup on the indexer.


svn path=/trunk/mcs/; revision=138194
Jb Evain 16 년 전
부모
커밋
43f59cd5b9
2개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 0
      mcs/class/System.Core/System.Linq/ChangeLog
  2. 4 2
      mcs/class/System.Core/System.Linq/Lookup.cs

+ 4 - 0
mcs/class/System.Core/System.Linq/ChangeLog

@@ -1,3 +1,7 @@
+2009-07-20  Jb Evain  <[email protected]>
+
+	* Lookup.cs: avoid a double dictionary lookup on the indexer.
+
 2009-07-19 Gonzalo Paniagua Javier <[email protected]>
 
 	* Lookup.cs: when there are no matching elements, return an empty

+ 4 - 2
mcs/class/System.Core/System.Linq/Lookup.cs

@@ -45,8 +45,10 @@ namespace System.Linq {
 
 		public IEnumerable<TElement> this [TKey key] {
 			get {
-				if (groups.ContainsKey (key))
-					return groups [key];
+				IGrouping<TKey, TElement> group;
+				if (groups.TryGetValue (key, out group))
+					return group;
+
 				return new TElement [0];
 			}
 		}