summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/ArraySegment.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/ArraySegment.cs')
-rw-r--r--src/mscorlib/src/System/ArraySegment.cs14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/mscorlib/src/System/ArraySegment.cs b/src/mscorlib/src/System/ArraySegment.cs
index b767e7bd77..03556e492a 100644
--- a/src/mscorlib/src/System/ArraySegment.cs
+++ b/src/mscorlib/src/System/ArraySegment.cs
@@ -15,8 +15,6 @@
using System.Collections;
using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using System.Diagnostics;
using System.Diagnostics.Contracts;
namespace System
@@ -46,14 +44,10 @@ namespace System
public ArraySegment(T[] array, int offset, int count)
{
- if (array == null)
- ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
- if (offset < 0)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.offset, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
- if (count < 0)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
- if (array.Length - offset < count)
- ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
+ // Validate arguments, check is minimal instructions with reduced branching for inlinable fast-path
+ // Failure should be rare and location determination and message is delegated to failure functions
+ if (array == null || (offset | count) < 0 || (array.Length - offset < count))
+ ThrowHelper.ThrowArraySegmentCtorValidationFailedExceptions(array, offset, count);
Contract.EndContractBlock();
_array = array;