Implements some micro-optimizations
All checks were successful
Build / Build (push) Successful in 51s

This commit is contained in:
2025-07-05 15:46:32 +02:00
parent c795f20e54
commit 8a857ed232
11 changed files with 80 additions and 21 deletions

View File

@@ -1,3 +1,5 @@
using PkmnLib.Static.Utils;
namespace PkmnLib.Dynamic.Events;
/// <summary>
@@ -10,8 +12,18 @@ namespace PkmnLib.Dynamic.Events;
/// </remarks>
public readonly record struct EventBatchId()
{
private static readonly RandomImpl RootRandom = new();
private static readonly ThreadLocal<RandomImpl> Random = new(() =>
{
lock (RootRandom)
{
return new RandomImpl(RootRandom.GetInt());
}
});
/// <summary>
/// The unique identifier for this batch of events.
/// </summary>
public Guid Id { get; init; } = Guid.NewGuid();
public Guid Id { get; init; } = Random.Value.NewGuid();
}