Simplified the RemoveItem logic since we have more robust validation
authorAndrew Hoefling <andrew@hoeflingsoftware.com>
Thu, 7 Mar 2019 00:34:57 +0000 (19:34 -0500)
committerSantiago Fernandez Madero <safern@microsoft.com>
Fri, 8 Mar 2019 19:20:58 +0000 (11:20 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/7e487423d166cf2768d3f6630071d908832f0fe4

src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs

index f6d7f98..40268ea 100644 (file)
@@ -220,15 +220,9 @@ namespace System.Collections.ObjectModel
             if (index > items.Count - count)
             {
                 ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
-            }
-
-            int length = items.Count;
-            if (index < items.Count - count)
-            {
-                length = index + count;
-            }
+            }            
 
-            for (int i = index; i < length; i++)
+            for (int i = 0; i < count; i++)
             {
                 RemoveItem(index);
             }