Skip to content

Commit

Permalink
fix: revert changes by merge conflict from #89
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Jan 6, 2024
1 parent 2a89c8e commit ceb7989
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions X10D/src/Collections/ByteExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -35,7 +35,7 @@ public static bool[] Unpack(this byte value)
/// <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)
Expand All @@ -52,7 +52,7 @@ public static void Unpack(this byte value, Span<bool> destination)
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++)
Expand All @@ -61,7 +61,7 @@ internal static void UnpackInternal_Fallback(this byte value, Span<bool> destina
}
}

[MethodImpl(CompilerResources.MethodImplOptions)]
[MethodImpl(CompilerResources.MaxOptimization)]
internal unsafe static void UnpackInternal_Ssse3(this byte value, Span<bool> destination)
{
fixed (bool* pDestination = destination)
Expand Down
8 changes: 4 additions & 4 deletions X10D/src/Collections/Int16Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -35,7 +35,7 @@ public static bool[] Unpack(this short value)
/// <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)
Expand All @@ -52,7 +52,7 @@ public static void Unpack(this short value, Span<bool> destination)
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++)
Expand All @@ -61,7 +61,7 @@ internal static void UnpackInternal_Fallback(this short value, Span<bool> destin
}
}

[MethodImpl(CompilerResources.MethodImplOptions)]
[MethodImpl(CompilerResources.MaxOptimization)]
internal unsafe static void UnpackInternal_Ssse3(this short value, Span<bool> destination)
{
fixed (bool* pDestination = destination)
Expand Down
8 changes: 4 additions & 4 deletions X10D/src/Collections/Int32Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -35,7 +35,7 @@ public static bool[] Unpack(this int value)
/// <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)
Expand All @@ -58,7 +58,7 @@ public static void Unpack(this int value, Span<bool> destination)
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++)
Expand All @@ -67,7 +67,7 @@ internal static void UnpackInternal_Fallback(this int value, Span<bool> destinat
}
}

[MethodImpl(CompilerResources.MethodImplOptions)]
[MethodImpl(CompilerResources.MaxOptimization)]
internal static unsafe void UnpackInternal_Ssse3(this int value, Span<bool> destination)
{
fixed (bool* pDestination = destination)
Expand Down
4 changes: 2 additions & 2 deletions X10D/src/CompilerServices/CompilerResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
32 changes: 16 additions & 16 deletions X10D/src/Core/SpanExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static Vector256<ulong> IntegerPackingMagicV256
/// </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);
Expand All @@ -62,7 +62,7 @@ public static bool Contains<T>(this Span<T> span, T value) where T : struct, Enu
/// </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>())
Expand Down Expand Up @@ -111,7 +111,7 @@ public static bool Contains<T>(this ReadOnlySpan<T> span, T value) where T : str
/// <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);
Expand All @@ -124,7 +124,7 @@ public static byte PackByte(this Span<bool> source)
/// <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)
{
Expand Down Expand Up @@ -171,7 +171,7 @@ public static short PackInt16(this Span<bool> source)
/// <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)
{
Expand Down Expand Up @@ -208,7 +208,7 @@ public static short PackInt16(this ReadOnlySpan<bool> source)
/// <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);
Expand All @@ -221,7 +221,7 @@ public static int PackInt32(this Span<bool> source)
/// <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)
{
Expand Down Expand Up @@ -266,7 +266,7 @@ public static int PackInt32(this ReadOnlySpan<bool> source)
/// <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);
Expand All @@ -279,7 +279,7 @@ public static long PackInt64(this Span<bool> source)
/// <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)
Expand All @@ -304,7 +304,7 @@ public static long PackInt64(this ReadOnlySpan<bool> source)
}

[Pure]
[MethodImpl(CompilerResources.MethodImplOptions)]
[MethodImpl(CompilerResources.MaxOptimization)]
internal static byte PackByteInternal_Fallback(this ReadOnlySpan<bool> source)
{
byte result = 0;
Expand All @@ -318,7 +318,7 @@ internal static byte PackByteInternal_Fallback(this ReadOnlySpan<bool> source)
}

[Pure]
[MethodImpl(CompilerResources.MethodImplOptions)]
[MethodImpl(CompilerResources.MaxOptimization)]
internal static short PackInt16Internal_Fallback(this ReadOnlySpan<bool> source)
{
short result = 0;
Expand All @@ -332,7 +332,7 @@ internal static short PackInt16Internal_Fallback(this ReadOnlySpan<bool> source)
}

[Pure]
[MethodImpl(CompilerResources.MethodImplOptions)]
[MethodImpl(CompilerResources.MaxOptimization)]
internal static int PackInt32Internal_Fallback(this ReadOnlySpan<bool> source)
{
var result = 0;
Expand All @@ -346,7 +346,7 @@ internal static int PackInt32Internal_Fallback(this ReadOnlySpan<bool> source)
}

[Pure]
[MethodImpl(CompilerResources.MethodImplOptions)]
[MethodImpl(CompilerResources.MaxOptimization)]
internal static byte PackByteInternal_Sse2(this ReadOnlySpan<bool> source)
{
unsafe
Expand All @@ -360,7 +360,7 @@ internal static byte PackByteInternal_Sse2(this ReadOnlySpan<bool> source)
}

[Pure]
[MethodImpl(CompilerResources.MethodImplOptions)]
[MethodImpl(CompilerResources.MaxOptimization)]
internal static short PackInt16Internal_Sse2(this ReadOnlySpan<bool> source)
{
unsafe
Expand All @@ -378,7 +378,7 @@ internal static short PackInt16Internal_Sse2(this ReadOnlySpan<bool> source)
}

[Pure]
[MethodImpl(CompilerResources.MethodImplOptions)]
[MethodImpl(CompilerResources.MaxOptimization)]
internal static int PackInt32Internal_Avx2(this ReadOnlySpan<bool> source)
{
unsafe
Expand All @@ -403,7 +403,7 @@ internal static int PackInt32Internal_Avx2(this ReadOnlySpan<bool> source)
}

[Pure]
[MethodImpl(CompilerResources.MethodImplOptions)]
[MethodImpl(CompilerResources.MaxOptimization)]
internal static int PackInt32Internal_Sse2(this ReadOnlySpan<bool> source)
{
unsafe
Expand Down
2 changes: 1 addition & 1 deletion X10D/src/Text/CharExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static string Repeat(this char value, int count)
/// <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)
Expand Down
4 changes: 2 additions & 2 deletions X10D/src/Text/CharSpanExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static int CountSubstring(this ReadOnlySpan<char> haystack, ReadOnlySpan<
/// <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)
Expand Down Expand Up @@ -117,7 +117,7 @@ public static string Repeat(this ReadOnlySpan<char> value, int count)
/// <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)
Expand Down
2 changes: 1 addition & 1 deletion X10D/src/Text/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ public static string Repeat(this string value, int count)
/// <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)
Expand Down

0 comments on commit ceb7989

Please sign in to comment.