From 0f13d625201c2a69922a59c679dd825070f28e98 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 30 Mar 2018 21:46:27 -0700 Subject: [PATCH 1/2] Make AsSpan(this string) ForceInline to be on par with AsSpan(this T[]) --- src/mscorlib/shared/System/MemoryExtensions.Fast.cs | 2 ++ src/mscorlib/shared/System/String.cs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/mscorlib/shared/System/MemoryExtensions.Fast.cs b/src/mscorlib/shared/System/MemoryExtensions.Fast.cs index d9e3af880482..e798be07a4fe 100644 --- a/src/mscorlib/shared/System/MemoryExtensions.Fast.cs +++ b/src/mscorlib/shared/System/MemoryExtensions.Fast.cs @@ -359,6 +359,7 @@ public static bool StartsWith(this ReadOnlySpan span, ReadOnlySpan v /// /// 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 @@ public static Span AsSpan(this T[] array, int start) /// /// The target string. /// Returns default when is null. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan AsSpan(this string text) { if (text == null) diff --git a/src/mscorlib/shared/System/String.cs b/src/mscorlib/shared/System/String.cs index a1251d6be0e9..42d21ba06870 100644 --- a/src/mscorlib/shared/System/String.cs +++ b/src/mscorlib/shared/System/String.cs @@ -360,6 +360,7 @@ public static string Create(int length, TState state, SpanAction(string value) => value != null ? new ReadOnlySpan(ref value.GetRawStringData(), value.Length) : default; From a970996642433f3fd316ebb2190ac9437ddfbea3 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 30 Mar 2018 23:18:57 -0700 Subject: [PATCH 2/2] CR feedback --- src/mscorlib/shared/System/MemoryExtensions.Fast.cs | 2 ++ src/mscorlib/shared/System/MemoryExtensions.cs | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mscorlib/shared/System/MemoryExtensions.Fast.cs b/src/mscorlib/shared/System/MemoryExtensions.Fast.cs index e798be07a4fe..d256887a9f7e 100644 --- a/src/mscorlib/shared/System/MemoryExtensions.Fast.cs +++ b/src/mscorlib/shared/System/MemoryExtensions.Fast.cs @@ -399,6 +399,7 @@ public static ReadOnlySpan AsSpan(this string text) /// /// 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) @@ -424,6 +425,7 @@ public static ReadOnlySpan AsSpan(this string text, int start) /// /// 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 1a3b33acc701..c3e1cd51fa44 100644 --- a/src/mscorlib/shared/System/MemoryExtensions.cs +++ b/src/mscorlib/shared/System/MemoryExtensions.cs @@ -68,7 +68,6 @@ public static ReadOnlySpan TrimEnd(this ReadOnlySpan span) /// /// 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 @@ public static ReadOnlySpan Trim(this ReadOnlySpan span, char trimCha /// /// 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 @@ ref MemoryMarshal.GetReference(span), /// no larger element, the bitwise complement of . /// /// - /// is . + /// is . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch( @@ -1228,7 +1226,7 @@ public static int BinarySearch( /// no larger element, the bitwise complement of . /// /// - /// is . + /// is . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch( @@ -1278,7 +1276,7 @@ public static int BinarySearch( /// no larger element, the bitwise complement of . /// /// - /// is . + /// is . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch( @@ -1302,7 +1300,7 @@ public static int BinarySearch( /// no larger element, the bitwise complement of . /// /// - /// is . + /// is . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch(