mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-07-25 07:57:11 +02:00
Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' (#5231)
* Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup * fix
This commit is contained in:
parent
2bf4555591
commit
e94d24f508
2 changed files with 13 additions and 17 deletions
|
@ -338,12 +338,10 @@ namespace Ryujinx.Input.Motion.CemuHook
|
|||
{
|
||||
int slot = inputData.Shared.Slot;
|
||||
|
||||
if (_motionData.ContainsKey(clientId))
|
||||
if (_motionData.TryGetValue(clientId, out var motionDataItem))
|
||||
{
|
||||
if (_motionData[clientId].ContainsKey(slot))
|
||||
if (motionDataItem.TryGetValue(slot, out var previousData))
|
||||
{
|
||||
MotionInput previousData = _motionData[clientId][slot];
|
||||
|
||||
previousData.Update(accelerometer, gyroscrope, timestamp, cemuHookConfig.Sensitivity, (float)cemuHookConfig.GyroDeadzone);
|
||||
}
|
||||
else
|
||||
|
@ -352,7 +350,7 @@ namespace Ryujinx.Input.Motion.CemuHook
|
|||
|
||||
input.Update(accelerometer, gyroscrope, timestamp, cemuHookConfig.Sensitivity, (float)cemuHookConfig.GyroDeadzone);
|
||||
|
||||
_motionData[clientId].Add(slot, input);
|
||||
motionDataItem.Add(slot, input);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue