mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-31 20:24:21 -04:00
Use new Random.Shared instead of creating new instances
This commit is contained in:
parent
556ef5f157
commit
d05062fec0
@ -420,7 +420,7 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
// Just return something so that apps that are expecting a value won't think the folders are empty
|
// Just return something so that apps that are expecting a value won't think the folders are empty
|
||||||
if (folder is ICollectionFolder || folder is UserView)
|
if (folder is ICollectionFolder || folder is UserView)
|
||||||
{
|
{
|
||||||
return new Random().Next(1, 10);
|
return Random.Shared.Next(1, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
return folder.GetChildCount(user);
|
return folder.GetChildCount(user);
|
||||||
|
@ -150,8 +150,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||||||
|
|
||||||
if (!_lockkey.HasValue)
|
if (!_lockkey.HasValue)
|
||||||
{
|
{
|
||||||
var rand = new Random();
|
_lockkey = (uint)Random.Shared.Next();
|
||||||
_lockkey = (uint)rand.Next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var lockKeyValue = _lockkey.Value;
|
var lockKeyValue = _lockkey.Value;
|
||||||
|
@ -316,7 +316,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
byte[] buffer = ArrayPool<byte>.Shared.Rent(size);
|
byte[] buffer = ArrayPool<byte>.Shared.Rent(size);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new Random().NextBytes(buffer);
|
Random.Shared.NextBytes(buffer);
|
||||||
return File(buffer, MediaTypeNames.Application.Octet);
|
return File(buffer, MediaTypeNames.Application.Octet);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -5,13 +5,11 @@ namespace Jellyfin.Extensions.Tests
|
|||||||
{
|
{
|
||||||
public static class ShuffleExtensionsTests
|
public static class ShuffleExtensionsTests
|
||||||
{
|
{
|
||||||
private static readonly Random _rng = new Random();
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void Shuffle_Valid_Correct()
|
public static void Shuffle_Valid_Correct()
|
||||||
{
|
{
|
||||||
byte[] original = new byte[1 << 6];
|
byte[] original = new byte[1 << 6];
|
||||||
_rng.NextBytes(original);
|
Random.Shared.NextBytes(original);
|
||||||
byte[] shuffled = (byte[])original.Clone();
|
byte[] shuffled = (byte[])original.Clone();
|
||||||
shuffled.Shuffle();
|
shuffled.Shuffle();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user