From 3632a515eccbba14e9393d83683f39e94690f42b Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sat, 31 Mar 2018 00:30:53 -0700 Subject: [PATCH] Make AsSpan(this string) ForceInline to be on par with AsSpan(this T[]) (#17368) --- src/mscorlib/shared/System/MemoryExtensions.Fast.cs | 4 ++++ src/mscorlib/shared/System/MemoryExtensions.cs | 10 ++++------ src/mscorlib/shared/System/String.cs | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mscorlib/shared/System/MemoryExtensions.Fast.cs b/src/mscorlib/shared/System/MemoryExtensions.Fast.cs index d9e3af8..d256887 100644 --- a/src/mscorlib/shared/System/MemoryExtensions.Fast.cs +++ b/src/mscorlib/shared/System/MemoryExtensions.Fast.cs @@ -359,6 +359,7 @@ namespace System /// /// Creates a new span over the portion of the target array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span AsSpan(this T[] array, int start) { if (array == null) @@ -380,6 +381,7 @@ namespace System /// /// The target string. /// Returns default when is null. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan AsSpan(this string text) { if (text == null) @@ -397,6 +399,7 @@ namespace System /// /// Thrown when the specified index is not in range (<0 or >text.Length). /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan AsSpan(this string text, int start) { if (text == null) @@ -422,6 +425,7 @@ namespace System /// /// Thrown when the specified index or is not in range. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan AsSpan(this string text, int start, int length) { if (text == null) diff --git a/src/mscorlib/shared/System/MemoryExtensions.cs b/src/mscorlib/shared/System/MemoryExtensions.cs index 1a3b33a..c3e1cd5 100644 --- a/src/mscorlib/shared/System/MemoryExtensions.cs +++ b/src/mscorlib/shared/System/MemoryExtensions.cs @@ -68,7 +68,6 @@ namespace System /// /// The source span from which the character is removed. /// The specified character to look for and remove. - //[MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan Trim(this ReadOnlySpan span, char trimChar) { return span.TrimStart(trimChar).TrimEnd(trimChar); @@ -79,7 +78,6 @@ namespace System /// /// The source span from which the character is removed. /// The specified character to look for and remove. - //[MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimStart(this ReadOnlySpan span, char trimChar) { int start = 0; @@ -1204,7 +1202,7 @@ namespace System /// no larger element, the bitwise complement of . /// /// - /// is . + /// is . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch( @@ -1228,7 +1226,7 @@ namespace System /// no larger element, the bitwise complement of . /// /// - /// is . + /// is . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch( @@ -1278,7 +1276,7 @@ namespace System /// no larger element, the bitwise complement of . /// /// - /// is . + /// is . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch( @@ -1302,7 +1300,7 @@ namespace System /// no larger element, the bitwise complement of . /// /// - /// is . + /// is . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch( diff --git a/src/mscorlib/shared/System/String.cs b/src/mscorlib/shared/System/String.cs index a1251d6..42d21ba 100644 --- a/src/mscorlib/shared/System/String.cs +++ b/src/mscorlib/shared/System/String.cs @@ -360,6 +360,7 @@ namespace System return result; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator ReadOnlySpan(string value) => value != null ? new ReadOnlySpan(ref value.GetRawStringData(), value.Length) : default; -- 2.7.4