From e098da98a749fa9ffff6f5542488f8b5ef740ae7 Mon Sep 17 00:00:00 2001 From: Ahson Ahmed Khan Date: Fri, 31 Mar 2017 17:10:50 -0700 Subject: [PATCH] Removing Slice on string overloads and adding AsSpan (dotnet/coreclr#10544) Commit migrated from https://github.com/dotnet/coreclr/commit/ed2f9533cfcc1b9832d302169d34362da04121fc --- src/coreclr/src/mscorlib/src/System/Span.cs | 45 +---------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/src/coreclr/src/mscorlib/src/System/Span.cs b/src/coreclr/src/mscorlib/src/System/Span.cs index 51ed0f2..4211083 100644 --- a/src/coreclr/src/mscorlib/src/System/Span.cs +++ b/src/coreclr/src/mscorlib/src/System/Span.cs @@ -503,56 +503,13 @@ namespace System /// Thrown when is a null /// reference (Nothing in Visual Basic). [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReadOnlySpan Slice(this string text) + public static ReadOnlySpan AsSpan(this string text) { if (text == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text); return new ReadOnlySpan(ref text.GetFirstCharRef(), text.Length); } - - /// - /// Creates a new readonly span over the portion of the target string, beginning at 'start'. - /// - /// The target string. - /// The index at which to begin this slice. - /// Thrown when is a null - /// reference (Nothing in Visual Basic). - /// - /// Thrown when the specified index is not in range (<0 or >Length). - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReadOnlySpan Slice(this string text, int start) - { - if (text == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text); - if ((uint)start > (uint)text.Length) - ThrowHelper.ThrowArgumentOutOfRangeException(); - - return new ReadOnlySpan(ref Unsafe.Add(ref text.GetFirstCharRef(), start), text.Length - start); - } - - /// - /// Creates a new readonly span over the portion of the target string, beginning at , of given . - /// - /// The target string. - /// The index at which to begin this slice. - /// The number of items in the span. - /// Thrown when is a null - /// reference (Nothing in Visual Basic). - /// - /// Thrown when the specified or end index is not in range (<0 or >&eq;Length). - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReadOnlySpan Slice(this string text, int start, int length) - { - if (text == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text); - if ((uint)start > (uint)text.Length || (uint)length > (uint)(text.Length - start)) - ThrowHelper.ThrowArgumentOutOfRangeException(); - - return new ReadOnlySpan(ref Unsafe.Add(ref text.GetFirstCharRef(), start), length); - } } internal static class SpanHelper -- 2.7.4