Avoid some heap allocations
This commit is contained in:
committed by
Sebastiaan Janssen
parent
2723e4f77c
commit
db43799d0f
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user