Bug 10670 fix.
[mono.git] / mcs / class / System / System.Text.RegularExpressions / GroupCollection.cs
index dcf388561c97f4306764c4741aadf3a51d5ba17b..5ff2383c9b9e372f8ea80ebf59bda2f5cdf25608 100644 (file)
@@ -46,7 +46,7 @@ namespace System.Text.RegularExpressions
                        list = new Group [n];
                }
 
-               public virtual int Count {
+               public int Count {
                        get { return list.Length; }
                }
 
@@ -54,7 +54,7 @@ namespace System.Text.RegularExpressions
                        get { return true; }
                }
 
-               public virtual bool IsSynchronized {
+               public bool IsSynchronized {
                        get { return false; }
                }
 
@@ -74,11 +74,10 @@ namespace System.Text.RegularExpressions
 
                public Group this [string groupName] {
                        get {
-                               foreach (Group g in list) {
-                                       if (!(g is Match))
-                                               continue;
-
-                                       int index = ((Match)g).Regex.GroupNumberFromName (groupName);
+                               // The 0th group is the match.
+                               Match m = (Match) list [0];
+                               if (m != Match.Empty) {
+                                       int index = m.Regex.GroupNumberFromName (groupName);
                                        if (index != -1)
                                                return this [index];
                                }
@@ -87,16 +86,16 @@ namespace System.Text.RegularExpressions
                        }
                }
 
-               public virtual object SyncRoot {
+               public object SyncRoot {
                        get { return list; }
                }
 
-               public virtual void CopyTo (Array array, int index)
+               public void CopyTo (Array array, int index)
                {
                        list.CopyTo (array, index);
                }
 
-               public virtual IEnumerator GetEnumerator ()
+               public IEnumerator GetEnumerator ()
                {
                        return list.GetEnumerator ();
                }