mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 01:58:47 +00:00
fix: revert changes by merge conflict from #89
This commit is contained in:
parent
2a89c8e6fe
commit
ceb7989d2d
@ -20,7 +20,7 @@ public static class ByteExtensions
|
||||
/// <param name="value">The value to unpack.</param>
|
||||
/// <returns>An array of <see cref="bool" /> with length 8.</returns>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool[] Unpack(this byte value)
|
||||
{
|
||||
var buffer = new bool[Size];
|
||||
@ -35,7 +35,7 @@ public static class ByteExtensions
|
||||
/// <param name="destination">When this method returns, contains the unpacked booleans from <paramref name="value" />.</param>
|
||||
/// <exception cref="ArgumentException"><paramref name="destination" /> is not large enough to contain the result.</exception>
|
||||
[ExcludeFromCodeCoverage]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static void Unpack(this byte value, Span<bool> destination)
|
||||
{
|
||||
if (destination.Length < Size)
|
||||
@ -52,7 +52,7 @@ public static class ByteExtensions
|
||||
UnpackInternal_Fallback(value, destination);
|
||||
}
|
||||
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static void UnpackInternal_Fallback(this byte value, Span<bool> destination)
|
||||
{
|
||||
for (var index = 0; index < Size; index++)
|
||||
@ -61,7 +61,7 @@ public static class ByteExtensions
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal unsafe static void UnpackInternal_Ssse3(this byte value, Span<bool> destination)
|
||||
{
|
||||
fixed (bool* pDestination = destination)
|
||||
|
@ -20,7 +20,7 @@ public static class Int16Extensions
|
||||
/// <param name="value">The value to unpack.</param>
|
||||
/// <returns>An array of <see cref="bool" /> with length 16.</returns>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool[] Unpack(this short value)
|
||||
{
|
||||
var ret = new bool[Size];
|
||||
@ -35,7 +35,7 @@ public static class Int16Extensions
|
||||
/// <param name="destination">When this method returns, contains the unpacked booleans from <paramref name="value" />.</param>
|
||||
/// <exception cref="ArgumentException"><paramref name="destination" /> is not large enough to contain the result.</exception>
|
||||
[ExcludeFromCodeCoverage]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static void Unpack(this short value, Span<bool> destination)
|
||||
{
|
||||
if (destination.Length < Size)
|
||||
@ -52,7 +52,7 @@ public static class Int16Extensions
|
||||
UnpackInternal_Fallback(value, destination);
|
||||
}
|
||||
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static void UnpackInternal_Fallback(this short value, Span<bool> destination)
|
||||
{
|
||||
for (var index = 0; index < Size; index++)
|
||||
@ -61,7 +61,7 @@ public static class Int16Extensions
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal unsafe static void UnpackInternal_Ssse3(this short value, Span<bool> destination)
|
||||
{
|
||||
fixed (bool* pDestination = destination)
|
||||
|
@ -20,7 +20,7 @@ public static class Int32Extensions
|
||||
/// <param name="value">The value to unpack.</param>
|
||||
/// <returns>An array of <see cref="bool" /> with length 32.</returns>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool[] Unpack(this int value)
|
||||
{
|
||||
var ret = new bool[Size];
|
||||
@ -35,7 +35,7 @@ public static class Int32Extensions
|
||||
/// <param name="destination">When this method returns, contains the unpacked booleans from <paramref name="value" />.</param>
|
||||
/// <exception cref="ArgumentException"><paramref name="destination" /> is not large enough to contain the result.</exception>
|
||||
[ExcludeFromCodeCoverage]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static void Unpack(this int value, Span<bool> destination)
|
||||
{
|
||||
if (destination.Length < Size)
|
||||
@ -58,7 +58,7 @@ public static class Int32Extensions
|
||||
UnpackInternal_Fallback(value, destination);
|
||||
}
|
||||
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static void UnpackInternal_Fallback(this int value, Span<bool> destination)
|
||||
{
|
||||
for (var index = 0; index < Size; index++)
|
||||
@ -67,7 +67,7 @@ public static class Int32Extensions
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static unsafe void UnpackInternal_Ssse3(this int value, Span<bool> destination)
|
||||
{
|
||||
fixed (bool* pDestination = destination)
|
||||
|
@ -4,6 +4,6 @@ namespace X10D.CompilerServices;
|
||||
|
||||
internal static class CompilerResources
|
||||
{
|
||||
public const MethodImplOptions MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining |
|
||||
System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization;
|
||||
public const MethodImplOptions MaxOptimization = MethodImplOptions.AggressiveInlining |
|
||||
MethodImplOptions.AggressiveOptimization;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public static class SpanExtensions
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentException">The size of <typeparamref name="T" /> is unsupported.</exception>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool Contains<T>(this Span<T> span, T value) where T : struct, Enum
|
||||
{
|
||||
return Contains((ReadOnlySpan<T>)span, value);
|
||||
@ -62,7 +62,7 @@ public static class SpanExtensions
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentException">The size of <typeparamref name="T" /> is unsupported.</exception>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static bool Contains<T>(this ReadOnlySpan<T> span, T value) where T : struct, Enum
|
||||
{
|
||||
switch (Unsafe.SizeOf<T>())
|
||||
@ -111,7 +111,7 @@ public static class SpanExtensions
|
||||
/// <returns>An 8-bit unsigned integer containing the packed booleans.</returns>
|
||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 8 elements.</exception>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static byte PackByte(this Span<bool> source)
|
||||
{
|
||||
return PackByte((ReadOnlySpan<bool>)source);
|
||||
@ -124,7 +124,7 @@ public static class SpanExtensions
|
||||
/// <returns>An 8-bit unsigned integer containing the packed booleans.</returns>
|
||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 8 elements.</exception>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static byte PackByte(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
@ -171,7 +171,7 @@ public static class SpanExtensions
|
||||
/// <returns>A 16-bit signed integer containing the packed booleans.</returns>
|
||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 16 elements.</exception>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static short PackInt16(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
@ -208,7 +208,7 @@ public static class SpanExtensions
|
||||
/// <returns>A 32-bit signed integer containing the packed booleans.</returns>
|
||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 32 elements.</exception>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static int PackInt32(this Span<bool> source)
|
||||
{
|
||||
return PackInt32((ReadOnlySpan<bool>)source);
|
||||
@ -221,7 +221,7 @@ public static class SpanExtensions
|
||||
/// <returns>A 32-bit signed integer containing the packed booleans.</returns>
|
||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 32 elements.</exception>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static int PackInt32(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
@ -266,7 +266,7 @@ public static class SpanExtensions
|
||||
/// <returns>A 64-bit signed integer containing the packed booleans.</returns>
|
||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 64 elements.</exception>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static long PackInt64(this Span<bool> source)
|
||||
{
|
||||
return PackInt64((ReadOnlySpan<bool>)source);
|
||||
@ -279,7 +279,7 @@ public static class SpanExtensions
|
||||
/// <returns>A 64-bit signed integer containing the packed booleans.</returns>
|
||||
/// <exception cref="ArgumentException"><paramref name="source" /> contains more than 64 elements.</exception>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static long PackInt64(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
switch (source.Length)
|
||||
@ -304,7 +304,7 @@ public static class SpanExtensions
|
||||
}
|
||||
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static byte PackByteInternal_Fallback(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
byte result = 0;
|
||||
@ -318,7 +318,7 @@ public static class SpanExtensions
|
||||
}
|
||||
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static short PackInt16Internal_Fallback(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
short result = 0;
|
||||
@ -332,7 +332,7 @@ public static class SpanExtensions
|
||||
}
|
||||
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static int PackInt32Internal_Fallback(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
var result = 0;
|
||||
@ -346,7 +346,7 @@ public static class SpanExtensions
|
||||
}
|
||||
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static byte PackByteInternal_Sse2(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
unsafe
|
||||
@ -360,7 +360,7 @@ public static class SpanExtensions
|
||||
}
|
||||
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static short PackInt16Internal_Sse2(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
unsafe
|
||||
@ -378,7 +378,7 @@ public static class SpanExtensions
|
||||
}
|
||||
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static int PackInt32Internal_Avx2(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
unsafe
|
||||
@ -403,7 +403,7 @@ public static class SpanExtensions
|
||||
}
|
||||
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
internal static int PackInt32Internal_Sse2(this ReadOnlySpan<bool> source)
|
||||
{
|
||||
unsafe
|
||||
|
@ -54,7 +54,7 @@ public static class CharExtensions
|
||||
/// <param name="value">The character to repeat.</param>
|
||||
/// <param name="count">The number of times to repeat.</param>
|
||||
/// <param name="destination">The span of characters into which the repeated characters will be written.</param>
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static void Repeat(this char value, int count, Span<char> destination)
|
||||
{
|
||||
if (count < 0)
|
||||
|
@ -82,7 +82,7 @@ public static class CharSpanExtensions
|
||||
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count" /> is less than 0.</exception>
|
||||
[Pure]
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static string Repeat(this ReadOnlySpan<char> value, int count)
|
||||
{
|
||||
switch (count)
|
||||
@ -117,7 +117,7 @@ public static class CharSpanExtensions
|
||||
/// <exception cref="ArgumentException">
|
||||
/// <paramref name="destination" /> is too short to contain the repeated string.
|
||||
/// </exception>
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static void Repeat(this ReadOnlySpan<char> value, int count, Span<char> destination)
|
||||
{
|
||||
if (count < 0)
|
||||
|
@ -894,7 +894,7 @@ public static class StringExtensions
|
||||
/// <exception cref="ArgumentException">
|
||||
/// <paramref name="destination" /> is too short to contain the repeated string.
|
||||
/// </exception>
|
||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||
public static void Repeat(this string value, int count, Span<char> destination)
|
||||
{
|
||||
if (value is null)
|
||||
|
Loading…
Reference in New Issue
Block a user