From 7e5aef990eb4c8d7b34fc5f8a9a1fd5ed326410d Mon Sep 17 00:00:00 2001 From: Mandar Sahasrabuddhe Date: Sat, 25 Mar 2017 06:51:56 +0530 Subject: [PATCH] CoreFx 14486 Remove argument validation in DangerousCreate (#10462) --- src/mscorlib/src/System/ReadOnlySpan.cs | 16 +--------------- src/mscorlib/src/System/Span.cs | 16 +--------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/src/mscorlib/src/System/ReadOnlySpan.cs b/src/mscorlib/src/System/ReadOnlySpan.cs index ccbca3c..72754d7 100644 --- a/src/mscorlib/src/System/ReadOnlySpan.cs +++ b/src/mscorlib/src/System/ReadOnlySpan.cs @@ -120,22 +120,8 @@ namespace System /// The managed object that contains the data to span over. /// A reference to data within that object. /// The number of elements the memory contains. - /// - /// Thrown when the specified object is null. - /// - /// - /// Thrown when the specified is negative. - /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReadOnlySpan DangerousCreate(object obj, ref T objectData, int length) - { - if (obj == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.obj); - if (length < 0) - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length); - - return new ReadOnlySpan(ref objectData, length); - } + public static ReadOnlySpan DangerousCreate(object obj, ref T objectData, int length) => new ReadOnlySpan(ref objectData, length); // Constructor for internal use only. [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/mscorlib/src/System/Span.cs b/src/mscorlib/src/System/Span.cs index e730582..e6620f8 100644 --- a/src/mscorlib/src/System/Span.cs +++ b/src/mscorlib/src/System/Span.cs @@ -137,22 +137,8 @@ namespace System /// The managed object that contains the data to span over. /// A reference to data within that object. /// The number of elements the memory contains. - /// - /// Thrown when the specified object is null. - /// - /// - /// Thrown when the specified is negative. - /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Span DangerousCreate(object obj, ref T objectData, int length) - { - if (obj == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.obj); - if (length < 0) - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length); - - return new Span(ref objectData, length); - } + public static Span DangerousCreate(object obj, ref T objectData, int length) => new Span(ref objectData, length); // Constructor for internal use only. [MethodImpl(MethodImplOptions.AggressiveInlining)] -- 2.7.4