Attached.

Juan C. Olivares
www.juancri.com

On 3/18/07, Miguel de Icaza <[EMAIL PROTECTED]> wrote:

Hello,

>
> Do you have any comment?. I could send a patch...

These numbers look fantastic.   We would love to see a patch.

> best regards
>
> Juan C. Olivares
> www.juancri.com
>
>
>
> _______________________________________________
> Mono-list maillist  -  [email protected]
> http://lists.ximian.com/mailman/listinfo/mono-list


Index: List.cs
===================================================================
--- List.cs	(revision 74551)
+++ List.cs	(working copy)
@@ -212,19 +212,33 @@
 				throw new ArgumentNullException ("match");
 		}
 		
-		// Maybe we could make this faster. For example, you could
-		// make a bit set with stackalloc for which elements to copy
-		// then you could size the array correctly.
 		public List <T> FindAll (Predicate <T> match)
 		{
-			CheckMatch (match);
-			List <T> f = new List <T> ();
-			
-			foreach (T t in this)
-				if (match (t))
-					f.Add (t);
-			
-			return f;
+			this.CheckMatch (match);	
+		
+			unsafe
+			{
+				bool *bools = stackalloc bool [numbers.Count];
+				bool *ptr = bools;
+				int found = 0;
+				
+				for (int i = 0; i < this._size; i++)
+				{
+					if (predicate (this._items [i]))
+					{
+						(*ptr) = true;
+						found++;
+					}
+					ptr++;
+				}
+				
+				List <T> results = new List <T> (found);
+				for (int i = 0; i < this._size; i++)
+					if (bools [i])
+						results.Add (this._items [i]);
+				
+				return results;
+			}
 		}
 		
 		public int FindIndex (Predicate <T> match)
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to