Compare commits

...

2 Commits

Author SHA1 Message Date
Berkan Diler
11aae9cfbc Make use of Random.Shared (#3852) 2022-11-16 15:34:18 -03:00
Berkan Diler
b96794e72b Use new LINQ Order() methods (#3851) 2022-11-16 15:17:03 -03:00
6 changed files with 7 additions and 10 deletions

View File

@@ -525,7 +525,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
private static void DeclareInputAttributesPerPatch(CodeGenContext context, HashSet<int> attrs)
{
foreach (int attr in attrs.OrderBy(x => x))
foreach (int attr in attrs.Order())
{
DeclareInputAttributePerPatch(context, attr);
}
@@ -658,7 +658,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
private static void DeclareUsedOutputAttributesPerPatch(CodeGenContext context, HashSet<int> attrs)
{
foreach (int attr in attrs.OrderBy(x => x))
foreach (int attr in attrs.Order())
{
DeclareOutputAttributePerPatch(context, attr);
}

View File

@@ -207,7 +207,7 @@ namespace Ryujinx.Graphics.Shader.Translation
if (context.Config.NextUsedInputAttributesPerPatch != null)
{
foreach (int vecIndex in context.Config.NextUsedInputAttributesPerPatch.OrderBy(x => x))
foreach (int vecIndex in context.Config.NextUsedInputAttributesPerPatch.Order())
{
InitializeOutput(context, AttributeConsts.UserAttributePerPatchBase + vecIndex * 16, perPatch: true);
}

View File

@@ -266,9 +266,8 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator
// NOTE: Calls nn::friends::detail::service::core::PlayHistoryManager::GetInstance and stores the instance.
byte[] randomBytes = new byte[8];
Random random = new Random();
random.NextBytes(randomBytes);
Random.Shared.NextBytes(randomBytes);
// NOTE: Calls nn::friends::detail::service::core::UuidManager::GetInstance and stores the instance.
// Then call nn::friends::detail::service::core::AccountStorageManager::GetInstance and store the instance.

View File

@@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
{
byte[] uuid = new byte[9];
new Random().NextBytes(uuid);
Random.Shared.NextBytes(uuid);
uuid[3] = (byte)(0x88 ^ uuid[0] ^ uuid[1] ^ uuid[2]);
uuid[8] = (byte)(uuid[3] ^ uuid[4] ^ uuid[5] ^ uuid[6]);

View File

@@ -89,7 +89,7 @@ namespace Ryujinx.HLE.HOS.Services.Prepo
{
byte[] randomBuffer = new byte[8];
new Random().NextBytes(randomBuffer);
Random.Shared.NextBytes(randomBuffer);
_systemSessionId = BitConverter.ToUInt64(randomBuffer, 0);
}

View File

@@ -32,8 +32,6 @@ namespace Ryujinx.HLE.HOS.Services.Ro
private KProcess _owner;
private IVirtualMemoryManager _ownerMm;
private static Random _random = new Random();
public IRoInterface(ServiceCtx context)
{
_nrrInfos = new List<NrrInfo>(MaxNrr);
@@ -283,7 +281,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
{
while (true)
{
ulong randomOffset = (ulong)(uint)_random.Next(0, (int)addressSpacePageLimit) << 12;
ulong randomOffset = (ulong)(uint)Random.Shared.Next(0, (int)addressSpacePageLimit) << 12;
targetAddress = memMgr.GetAddrSpaceBaseAddr() + randomOffset;