Remove leftover methods

このコミットが含まれているのは:
Sergio Pedri committed 2023-10-01 00:56:36 +02:00
1 親 aae13e1c3e
コミット ba7d015a75
1ファイル変更
-92
-92
ファイルの表示
@@ -1,10 +1,6 @@
using System;
#if NET6_0_OR_GREATER
using System.Buffers.Text;
#endif
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace ComputeSharp.D2D1.Shaders.Interop.Buffers;
@@ -30,22 +26,6 @@ internal static class ArrayPoolBinaryWriterExtensions
writer.Advance(sizeof(T));
}
/// <summary>
/// Writes the raw value of type <typeparamref name="T"/> into the buffer.
/// </summary>
/// <typeparam name="T">The type of value to write.</typeparam>
/// <param name="writer">The target <see cref="ArrayPoolBufferWriter{T}"/> instance to write data to.</param>
/// <param name="value">The value to write.</param>
public static unsafe void WriteRaw<T>(this ref ArrayPoolBufferWriter<T> writer, scoped in T value)
where T : unmanaged
{
Span<T> span = writer.GetSpan(1);
MemoryMarshal.GetReference(span) = value;
writer.Advance(1);
}
/// <summary>
/// Writes the raw data from the input <see cref="ReadOnlySpan{T}"/> into the buffer.
/// </summary>
@@ -61,76 +41,4 @@ internal static class ArrayPoolBinaryWriterExtensions
writer.Advance(data.Length);
}
#if !NET6_0_OR_GREATER
/// <summary>
/// Writes the raw data from the input <see cref="ReadOnlySpan{T}"/> into the buffer.
/// </summary>
/// <param name="writer">The target <see cref="ArrayPoolBufferWriter{T}"/> instance to write data to.</param>
/// <param name="data">The data to write.</param>
public static void WriteRaw(this ref ArrayPoolBufferWriter<char> writer, string data)
{
Span<char> span = writer.GetSpan(data.Length);
data.AsSpan().CopyTo(span);
writer.Advance(data.Length);
}
#endif
/// <summary>
/// Writes an <see langword="int"/> value as UTF8 bytes into the buffer.
/// </summary>
/// <param name="writer">The target <see cref="ArrayPoolBufferWriter{T}"/> instance to write data to.</param>
/// <param name="value">The value to write.</param>
public static void WriteAsUtf8(this ref ArrayPoolBufferWriter<byte> writer, int value)
{
#if NET6_0_OR_GREATER
// Get a span of at least 10 elements (10 is the length of int.MaxValue as text)
Span<byte> span = writer.GetSpan(10);
_ = Utf8Formatter.TryFormat(value, span, out int bytesWritten);
writer.Advance(bytesWritten);
#else
// Just accept the allocation on .NET Standard 2.0
writer.WriteAsUtf8(value.ToString());
#endif
}
/// <summary>
/// Writes text as UTF8 bytes into the buffer.
/// </summary>
/// <param name="writer">The target <see cref="ArrayPoolBufferWriter{T}"/> instance to write data to.</param>
/// <param name="text">The text to write.</param>
public static void WriteAsUtf8(this ref ArrayPoolBufferWriter<byte> writer, string text)
{
int maximumByteSize = Encoding.UTF8.GetMaxByteCount(text.Length);
Span<byte> span = writer.GetSpan(maximumByteSize);
int writtenBytes = Encoding.UTF8.GetBytes(text.AsSpan(), span);
writer.Advance(writtenBytes);
}
/// <summary>
/// Writes an <see langword="int"/> value as Unicode bytes into the buffer.
/// </summary>
/// <param name="writer">The target <see cref="ArrayPoolBufferWriter{T}"/> instance to write data to.</param>
/// <param name="value">The value to write.</param>
public static void WriteAsUnicode(this ref ArrayPoolBufferWriter<char> writer, int value)
{
#if NET6_0_OR_GREATER
// Get a span of at least 10 elements (10 is the length of int.MaxValue as text)
Span<char> span = writer.GetSpan(10);
_ = value.TryFormat(span, out int charsWritten);
writer.Advance(charsWritten);
#else
// Just accept the allocation on .NET Standard 2.0
writer.WriteRaw(value.ToString().AsSpan());
#endif
}
}