summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Collections/Generic/List.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Collections/Generic/List.cs')
-rw-r--r--src/mscorlib/src/System/Collections/Generic/List.cs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mscorlib/src/System/Collections/Generic/List.cs b/src/mscorlib/src/System/Collections/Generic/List.cs
index 3e2947f5f9..362e26599d 100644
--- a/src/mscorlib/src/System/Collections/Generic/List.cs
+++ b/src/mscorlib/src/System/Collections/Generic/List.cs
@@ -20,7 +20,6 @@ namespace System.Collections.Generic {
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Collections.ObjectModel;
- using System.Security.Permissions;
// Implements a variable-size List that uses an array of objects to store the
// elements. A List has a capacity, which is the allocated length
@@ -927,7 +926,9 @@ namespace System.Collections.Generic {
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
Contract.EndContractBlock();
- Array.Reverse(_items, index, count);
+ if (count > 1) {
+ Array.Reverse(_items, index, count);
+ }
_version++;
}
@@ -966,7 +967,9 @@ namespace System.Collections.Generic {
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
Contract.EndContractBlock();
- Array.Sort<T>(_items, index, count, comparer);
+ if (count > 1) {
+ Array.Sort<T>(_items, index, count, comparer);
+ }
_version++;
}
@@ -976,9 +979,10 @@ namespace System.Collections.Generic {
}
Contract.EndContractBlock();
- if( _size > 0) {
+ if (_size > 1) {
ArraySortHelper<T>.Sort(_items, 0, _size, comparison);
}
+ _version++;
}
// ToArray returns an array containing the contents of the List.