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:
authorJb Evain <jbevain@gmail.com>2008-11-20 15:57:59 +0300
committerJb Evain <jbevain@gmail.com>2008-11-20 15:57:59 +0300
commit0058cfe9758bb4a4a6af058843a88420c7e14a85 (patch)
tree12a5356011d4b2f829f050d8c41e1f31be9d58d0 /mcs/class/System.Core/System.Linq/Enumerable.cs
parenteda8d0a80ead08377d9c38d5024720af149fe76e (diff)
2008-11-20 Jb Evain <jbevain@novell.com>
* Enumerable.cs (Any): optimize if we're operating on an ICollection. svn path=/trunk/mcs/; revision=119433
Diffstat (limited to 'mcs/class/System.Core/System.Linq/Enumerable.cs')
-rw-r--r--mcs/class/System.Core/System.Linq/Enumerable.cs4
1 files changed, 4 insertions, 0 deletions
diff --git a/mcs/class/System.Core/System.Linq/Enumerable.cs b/mcs/class/System.Core/System.Linq/Enumerable.cs
index ac06748b64a..75d4b20c124 100644
--- a/mcs/class/System.Core/System.Linq/Enumerable.cs
+++ b/mcs/class/System.Core/System.Linq/Enumerable.cs
@@ -116,6 +116,10 @@ namespace System.Linq
{
Check.Source (source);
+ var collection = source as ICollection<TSource>;
+ if (collection != null)
+ return collection.Count > 0;
+
using (var enumerator = source.GetEnumerator ())
return enumerator.MoveNext ();
}