Tiny optimization

This commit is contained in:
Marek Lemańczyk committed 2025-09-24 00:34:13 +02:00
1 parent c1ad705a4a
commit 15bc2686cc
1 file changed
+3 -7
+3 -7
View File
@@ -85,11 +85,8 @@ public static class ULongExtensions
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong Mod10(this ulong value)
{
ulong mod5 = value % 5UL;
return (value & 1UL) == 0UL
? mod5 switch
public static ulong Mod10(this ulong value) => (value & 1UL) == 0UL
? (value % 5UL) switch
{
0UL => 0UL,
1UL => 6UL,
@@ -97,7 +94,7 @@ public static class ULongExtensions
3UL => 8UL,
_ => 4UL,
}
: mod5 switch
: (value % 5UL) switch
{
0UL => 5UL,
1UL => 1UL,
@@ -105,7 +102,6 @@ public static class ULongExtensions
3UL => 3UL,
_ => 9UL,
};
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong Mod128(this ulong value) => value & 127UL;