Author: marek
Date: 2007-09-12 07:44:19 -0400 (Wed, 12 Sep 2007)
New Revision: 85678
Modified:
trunk/mcs/class/System.Core/System.Linq/ChangeLog
trunk/mcs/class/System.Core/System.Linq/Enumerable.cs
Log:
2007-09-12 Marek Safar <[EMAIL PROTECTED]>
* Enumerable.cs: Fixed GroupJoin logic. Reused DefaultIfEmpty
implementation.
Modified: trunk/mcs/class/System.Core/System.Linq/ChangeLog
===================================================================
--- trunk/mcs/class/System.Core/System.Linq/ChangeLog 2007-09-12 11:17:45 UTC
(rev 85677)
+++ trunk/mcs/class/System.Core/System.Linq/ChangeLog 2007-09-12 11:44:19 UTC
(rev 85678)
@@ -1,3 +1,8 @@
+2007-09-12 Marek Safar <[EMAIL PROTECTED]>
+
+ * Enumerable.cs: Fixed GroupJoin logic. Reused DefaultIfEmpty
+ implementation.
+
2007-09-11 Marek Safar <[EMAIL PROTECTED]>
* Enumerable.cs: Fixed Join recursion.
Modified: trunk/mcs/class/System.Core/System.Linq/Enumerable.cs
===================================================================
--- trunk/mcs/class/System.Core/System.Linq/Enumerable.cs 2007-09-12
11:17:45 UTC (rev 85677)
+++ trunk/mcs/class/System.Core/System.Linq/Enumerable.cs 2007-09-12
11:44:19 UTC (rev 85678)
@@ -526,24 +526,14 @@
public static IEnumerable<TSource> DefaultIfEmpty<TSource>
(this IEnumerable<TSource> source)
{
- if (source == null)
- throw new ArgumentNullException ();
-
- bool noYield = true;
- foreach (TSource item in source) {
- noYield = false;
- yield return item;
- }
-
- if (noYield)
- yield return default (TSource);
+ return DefaultIfEmpty (source, default (TSource));
}
public static IEnumerable<TSource> DefaultIfEmpty<TSource>
(this IEnumerable<TSource> source, TSource defaultValue)
{
if (source == null)
- throw new ArgumentNullException ();
+ throw new ArgumentNullException ("source");
bool noYield = true;
foreach (TSource item in source) {
@@ -880,7 +870,9 @@
TKey outerKey = outerKeySelector (element);
if (innerKeys.Contains (outerKey))
yield return resultSelector (element,
innerKeys [outerKey]);
- }
+ else
+ yield return resultSelector (element,
Empty<TInner> ());
+ }
}
#endregion
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches