MethodImplOptions.AggressiveOptimization & MethodImplOptions.AggressiveInlining optimized. Small optimizations.
This commit is contained in:
1 parent
7a242b3bfa
commit
05d3061c47
23 files changed
+628
-559
No files matched your search
@@ -1,3 +1,5 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace PerfectNumbers.Core.Cpu;
|
||||
|
||||
internal static class DeterministicRandomCpu
|
||||
@@ -7,6 +9,7 @@ internal static class DeterministicRandomCpu
|
||||
|
||||
private static long s_seedCounter;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static ulong NextUInt64()
|
||||
{
|
||||
ulong state = s_threadState;
|
||||
@@ -22,6 +25,7 @@ internal static class DeterministicRandomCpu
|
||||
return state * 2685821657736338717UL;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static UInt128 NextUInt128()
|
||||
{
|
||||
UInt128 high = (UInt128)NextUInt64();
|
||||
@@ -29,6 +33,7 @@ internal static class DeterministicRandomCpu
|
||||
return (high << 64) | low;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static ulong InitializeThreadState()
|
||||
{
|
||||
ulong seed = (ulong)Interlocked.Increment(ref s_seedCounter);
|
||||
|
||||
Reference in new issue
Block a user