1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-23 00:58:48 +00:00

[ci skip] style: reformat & cleanup solution

This commit is contained in:
Oliver Booth 2023-03-29 17:46:56 +01:00
parent 436f56d912
commit 4dd31ec1b6
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
10 changed files with 33 additions and 31 deletions

View File

@ -1,4 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using X10D.Collections;
using X10D.Core;
@ -10,7 +10,7 @@ public class SpanTest
[TestMethod]
public void Pack8Bit_Should_Pack_Correctly()
{
Span<bool> span = stackalloc bool[8] { true, true, false, false, true, true, false, false };
Span<bool> span = stackalloc bool[8] {true, true, false, false, true, true, false, false};
Assert.AreEqual(0b00110011, span.PackByte());
}
@ -29,9 +29,9 @@ public class SpanTest
[TestMethod]
public void Pack16Bit_Should_Pack_Correctly()
{
ReadOnlySpan<bool> span = stackalloc bool[16] {
false, false, true, false, true, false, true, true,
true, false, true, true, false, true, false, false,
ReadOnlySpan<bool> span = stackalloc bool[16]
{
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false,
};
Assert.AreEqual(0b00101101_11010100, span.PackInt16());
}
@ -51,11 +51,10 @@ public class SpanTest
[TestMethod]
public void Pack32Bit_Should_Pack_Correctly()
{
ReadOnlySpan<bool> span = stackalloc bool[] {
false, true, false, true, false, true, false, true,
true, false, true, false, true, false, true, false,
false, true, false, true, false, true, false, true,
true, false, true, false, true, false, true, false,
ReadOnlySpan<bool> span = stackalloc bool[]
{
false, true, false, true, false, true, false, true, true, false, true, false, true, false, true, false, false,
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false,
};
Assert.AreEqual(0b01010101_10101010_01010101_10101010, span.PackInt32());
}
@ -75,15 +74,12 @@ public class SpanTest
[TestMethod]
public void Pack64Bit_Should_Pack_Correctly()
{
ReadOnlySpan<bool> span = stackalloc bool[] {
true, false, true, false, false, true, false, true,
false, false, true, true, false, true, false, false,
true, true, true, false, true, false, false, true,
false, true, false, false, true, false, false, false,
false, true, true, false, true, false, true, true,
true, false, false, true, false, true, true, false,
false, true, true, false, true, false, true, true,
true, false, true, false, true, false, true, false,
ReadOnlySpan<bool> span = stackalloc bool[]
{
true, false, true, false, false, true, false, true, false, false, true, true, false, true, false, false, true,
true, true, false, true, false, false, true, false, true, false, false, true, false, false, false, false, true,
true, false, true, false, true, true, true, false, false, true, false, true, true, false, false, true, true,
false, true, false, true, true, true, false, true, false, true, false, true, false,
};
Assert.AreEqual(0b01010101_11010110_01101001_11010110_00010010_10010111_00101100_10100101, span.PackInt64());
}

View File

@ -66,7 +66,6 @@ public static class Vector4Extensions
public static System.Numerics.Vector4 ToSystemVector(this Vector4 vector)
{
return UnsafeUtility.As<Vector4, System.Numerics.Vector4>(ref vector);
}
/// <summary>

View File

@ -49,6 +49,7 @@ public static class Int32Extensions
Avx2Implementation(value, destination);
return;
}
if (Ssse3.IsSupported)
{
Ssse3Implementation(value, destination);
@ -85,6 +86,7 @@ public static class Int32Extensions
Avx.Store((byte*)pDestination, correctness);
}
}
unsafe static void Ssse3Implementation(int value, Span<bool> destination)
{
fixed (bool* pDestination = destination)

View File

@ -22,6 +22,7 @@ public static class SpanExtensions
{
#if NETCOREAPP3_0_OR_GREATER
private const ulong IntegerPackingMagic = 0x0102040810204080;
private static Vector64<ulong> IntegerPackingMagicV64
{
get => Vector64.Create(IntegerPackingMagic);
@ -174,7 +175,8 @@ public static class SpanExtensions
goto default;
}
fixed (bool* pSource = source) {
fixed (bool* pSource = source)
{
// TODO: .NET 8.0 Wasm support.
if (Sse2.IsSupported)
@ -336,6 +338,7 @@ public static class SpanExtensions
return (int)or2.GetElement(0);
}
if (Sse2.IsSupported)
{
Vector128<byte> load = Sse2.LoadVector128((byte*)pSource);
@ -357,6 +360,7 @@ public static class SpanExtensions
return (int)or2.GetElement(0);
}
if (AdvSimd.IsSupported)
{
// Hasn't been tested since March 6th 2023 (Reason: Unavailable hardware).

View File

@ -84,7 +84,8 @@ public static class RuneExtensions
{
return string.Create(count * 2, value, (span, rune) =>
{
unsafe {
unsafe
{
Span<byte> bytes = stackalloc byte[4];
value.EncodeToUtf8(bytes);