From 90966169fa5b8c816369ad9ee17935009a667ee5 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 5 Sep 2021 16:22:38 +0200 Subject: [PATCH] Minor code refactoring --- .../FormatInterpolatedStringHandler.cs | 16 +++------------- .../TryWriteFormatInterpolatedStringHandler.cs | 4 +--- 2 files changed, 4 insertions(+), 16 deletions(-) rename src/ComputeSharp/Core/Helpers/{ => System.Runtime.CompilerServices}/FormatInterpolatedStringHandler.cs (97%) rename src/ComputeSharp/Core/Helpers/{ => System.Runtime.CompilerServices}/TryWriteFormatInterpolatedStringHandler.cs (98%) diff --git a/src/ComputeSharp/Core/Helpers/FormatInterpolatedStringHandler.cs b/src/ComputeSharp/Core/Helpers/System.Runtime.CompilerServices/FormatInterpolatedStringHandler.cs similarity index 97% rename from src/ComputeSharp/Core/Helpers/FormatInterpolatedStringHandler.cs rename to src/ComputeSharp/Core/Helpers/System.Runtime.CompilerServices/FormatInterpolatedStringHandler.cs index d890842d..d50d40ae 100644 --- a/src/ComputeSharp/Core/Helpers/FormatInterpolatedStringHandler.cs +++ b/src/ComputeSharp/Core/Helpers/System.Runtime.CompilerServices/FormatInterpolatedStringHandler.cs @@ -11,7 +11,7 @@ namespace System.Runtime.CompilerServices; /// Provides a handler used by the language compiler to process interpolated strings into instances. /// [InterpolatedStringHandler] -public ref struct FormatInterpolatedStringHandler +internal ref struct FormatInterpolatedStringHandler { /// /// Minimum size array to rent from the pool. @@ -96,18 +96,6 @@ public ref struct FormatInterpolatedStringHandler public string ToStringAndClear() { string result = new(characters.Slice(0, position)); - - Clear(); - - return result; - } - - /// - /// Clears the handler, returning any rented array to the pool. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal void Clear() - { char[]? toReturn = arrayToReturnToPool; this = default; @@ -116,6 +104,8 @@ public ref struct FormatInterpolatedStringHandler { ArrayPool.Shared.Return(toReturn); } + + return result; } /// diff --git a/src/ComputeSharp/Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs b/src/ComputeSharp/Core/Helpers/System.Runtime.CompilerServices/TryWriteFormatInterpolatedStringHandler.cs similarity index 98% rename from src/ComputeSharp/Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs rename to src/ComputeSharp/Core/Helpers/System.Runtime.CompilerServices/TryWriteFormatInterpolatedStringHandler.cs index 7f97ec73..9fdb6b80 100644 --- a/src/ComputeSharp/Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs +++ b/src/ComputeSharp/Core/Helpers/System.Runtime.CompilerServices/TryWriteFormatInterpolatedStringHandler.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.ComponentModel; using System.Runtime.InteropServices; namespace System.Runtime.CompilerServices; @@ -9,9 +8,8 @@ namespace System.Runtime.CompilerServices; /// /// Provides a handler used by the language compiler to format interpolated strings into character spans. /// -[EditorBrowsable(EditorBrowsableState.Never)] [InterpolatedStringHandler] -public ref struct TryWriteFormatInterpolatedStringHandler +internal ref struct TryWriteFormatInterpolatedStringHandler { /// /// The destination buffer.