Skip to content

Commit

Permalink
Merge pull request #3051 from Guillermo-Santos/master
Browse files Browse the repository at this point in the history
Plug Random.NextBytes(Span<byte> buffer)
  • Loading branch information
MishaProductions authored Aug 9, 2024
2 parents 1648d48 + 87922ab commit 4f720d4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions source/Cosmos.System2_Plugs/System/RandomImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,19 @@ public static void NextBytes(Random aThis, byte[] buffer)
}
}

public static void NextBytes(Random aThis, Span<byte> buffer)
{
if (buffer == null)
{
return;
}

for (int i = 0; i < buffer.Length; i++)
{
buffer[i] = (byte)(InternalSample() % (byte.MaxValue + 1));
}
}

public static double NextDouble(Random aThis)
{
return Sample();
Expand Down

0 comments on commit 4f720d4

Please sign in to comment.