Avoid some heap allocations

This commit is contained in:
Henrik Gedionsen
2025-03-31 15:51:58 +02:00
committed by Sebastiaan Janssen
parent 2723e4f77c
commit db43799d0f
10 changed files with 33 additions and 38 deletions

View File

@@ -27,8 +27,8 @@ public static class IntExtensions
/// </returns>
public static Guid ToGuid(this int value)
{
var bytes = new byte[16];
BitConverter.GetBytes(value).CopyTo(bytes, 0);
Span<byte> bytes = stackalloc byte[16];
BitConverter.GetBytes(value).CopyTo(bytes);
return new Guid(bytes);
}
}