diff options
author | Stephen Toub <stoub@microsoft.com> | 2019-01-17 16:40:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-17 16:40:56 -0500 |
commit | 586a7912bf9aa84ce08882d79e52881b2f75366e (patch) | |
tree | 19b839f30138cf3a6067650f3cb5e8e69741835a /src/System.Private.CoreLib/src/System | |
parent | fdadb935df22baa947a610370dcfa772a5d89477 (diff) | |
download | coreclr-586a7912bf9aa84ce08882d79e52881b2f75366e.tar.gz coreclr-586a7912bf9aa84ce08882d79e52881b2f75366e.tar.bz2 coreclr-586a7912bf9aa84ce08882d79e52881b2f75366e.zip |
Clean up a few minor Span-related uses (#22038)
Some unnecessary Span to ReadOnlySpan casts.
Some places where new Span(...).Slice(...) can be replaced with AsSpan(...).
Etc.
Diffstat (limited to 'src/System.Private.CoreLib/src/System')
-rw-r--r-- | src/System.Private.CoreLib/src/System/Enum.cs | 2 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System/StubHelpers.cs | 4 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System/Text/StringBuilder.CoreCLR.cs | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/src/System.Private.CoreLib/src/System/Enum.cs b/src/System.Private.CoreLib/src/System/Enum.cs index c8c1fa11fc..e085517f58 100644 --- a/src/System.Private.CoreLib/src/System/Enum.cs +++ b/src/System.Private.CoreLib/src/System/Enum.cs @@ -269,7 +269,7 @@ namespace System const int SeparatorStringLength = 2; // ", " string result = string.FastAllocateString(checked(resultLength + (SeparatorStringLength * (foundItemsCount - 1)))); - Span<char> resultSpan = MemoryMarshal.CreateSpan(ref result.GetRawStringData(), result.Length); + Span<char> resultSpan = new Span<char>(ref result.GetRawStringData(), result.Length); string name = names[foundItems[--foundItemsCount]]; name.AsSpan().CopyTo(resultSpan); resultSpan = resultSpan.Slice(name.Length); diff --git a/src/System.Private.CoreLib/src/System/StubHelpers.cs b/src/System.Private.CoreLib/src/System/StubHelpers.cs index 3464d5a3ed..8bf9c56f06 100644 --- a/src/System.Private.CoreLib/src/System/StubHelpers.cs +++ b/src/System.Private.CoreLib/src/System/StubHelpers.cs @@ -45,7 +45,7 @@ namespace System.StubHelpers internal static char ConvertToManaged(byte nativeChar) { - Span<byte> bytes = new Span<byte>(ref nativeChar, 1); + var bytes = new ReadOnlySpan<byte>(ref nativeChar, 1); string str = Encoding.Default.GetString(bytes); return str[0]; } @@ -204,7 +204,7 @@ namespace System.StubHelpers byte* pBytes = (byte*)pNative; int nbBytes = string.strlen(pBytes); - sb.ReplaceBufferUtf8Internal(new Span<byte>(pBytes, nbBytes)); + sb.ReplaceBufferUtf8Internal(new ReadOnlySpan<byte>(pBytes, nbBytes)); } } diff --git a/src/System.Private.CoreLib/src/System/Text/StringBuilder.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Text/StringBuilder.CoreCLR.cs index 716c5cccaf..63afe45f32 100644 --- a/src/System.Private.CoreLib/src/System/Text/StringBuilder.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Text/StringBuilder.CoreCLR.cs @@ -38,7 +38,7 @@ namespace System.Text m_ChunkOffset = 0; } - internal void ReplaceBufferUtf8Internal(Span<byte> source) + internal void ReplaceBufferUtf8Internal(ReadOnlySpan<byte> source) { if (source.Length > m_MaxCapacity) throw new ArgumentOutOfRangeException("capacity", SR.ArgumentOutOfRange_Capacity); |