mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-08-02 13:37:12 +02:00
Slight Code Refactoring (#4373)
* Simplify return statements by using ternary expressions * Remove a redundant type conversion * Reduce nesting by inverting "if" statements * Try to improve code readability by using LINQ and inverting "if" statements * Try to improve code readability by using LINQ, using ternary expressions, and inverting "if" statements * Add line breaks to long LINQ * Add line breaks to long LINQ
This commit is contained in:
parent
7ca779a26d
commit
460f96967d
6 changed files with 68 additions and 106 deletions
|
@ -40,12 +40,7 @@ namespace Ryujinx.Horizon.Sdk.Sf
|
|||
var runtimeMetadata = context.Processor.GetRuntimeMetadata();
|
||||
Result result = context.Processor.PrepareForProcess(ref context, runtimeMetadata);
|
||||
|
||||
if (result.IsFailure)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return _invoke(ref context, _processor, runtimeMetadata, inRawData, ref outHeader);
|
||||
return result.IsFailure ? result : _invoke(ref context, _processor, runtimeMetadata, inRawData, ref outHeader);
|
||||
}
|
||||
|
||||
public static void GetCmifOutHeaderPointer(ref Span<CmifOutHeader> outHeader, ref Span<byte> outRawData)
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Ryujinx.Horizon.Sdk.Sf
|
|||
|
||||
public static void SerializeArg<T>(Span<byte> outRawData, int offset, T value) where T : unmanaged
|
||||
{
|
||||
MemoryMarshal.Cast<byte, T>(outRawData.Slice(offset, Unsafe.SizeOf<T>()))[0] = (T)value;
|
||||
MemoryMarshal.Cast<byte, T>(outRawData.Slice(offset, Unsafe.SizeOf<T>()))[0] = value;
|
||||
}
|
||||
|
||||
public static void SerializeCopyHandle(HipcMessageData response, int index, int value)
|
||||
|
|
|
@ -41,10 +41,8 @@ namespace Ryujinx.Horizon.Sdk.Sf
|
|||
{
|
||||
_args = args;
|
||||
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
foreach (CommandArg argInfo in args)
|
||||
{
|
||||
var argInfo = args[i];
|
||||
|
||||
switch (argInfo.Type)
|
||||
{
|
||||
case CommandArgType.Buffer:
|
||||
|
@ -239,14 +237,13 @@ namespace Ryujinx.Horizon.Sdk.Sf
|
|||
{
|
||||
return mode == HipcBufferMode.NonSecure;
|
||||
}
|
||||
else if (flags.HasFlag(HipcBufferFlags.MapTransferAllowsNonDevice))
|
||||
|
||||
if (flags.HasFlag(HipcBufferFlags.MapTransferAllowsNonDevice))
|
||||
{
|
||||
return mode == HipcBufferMode.NonDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
return mode == HipcBufferMode.Normal;
|
||||
}
|
||||
|
||||
return mode == HipcBufferMode.Normal;
|
||||
}
|
||||
|
||||
public void SetOutBuffers(HipcMessageData response, bool[] isBufferMapAlias)
|
||||
|
@ -261,28 +258,30 @@ namespace Ryujinx.Horizon.Sdk.Sf
|
|||
}
|
||||
|
||||
var flags = _args[i].BufferFlags;
|
||||
if (flags.HasFlag(HipcBufferFlags.Out))
|
||||
if (!flags.HasFlag(HipcBufferFlags.Out))
|
||||
{
|
||||
var buffer = _bufferRanges[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (flags.HasFlag(HipcBufferFlags.Pointer))
|
||||
var buffer = _bufferRanges[i];
|
||||
|
||||
if (flags.HasFlag(HipcBufferFlags.Pointer))
|
||||
{
|
||||
response.SendStatics[recvPointerIndex] = new HipcStaticDescriptor(buffer.Address, (ushort)buffer.Size, recvPointerIndex);
|
||||
}
|
||||
else if (flags.HasFlag(HipcBufferFlags.AutoSelect))
|
||||
{
|
||||
if (!isBufferMapAlias[i])
|
||||
{
|
||||
response.SendStatics[recvPointerIndex] = new HipcStaticDescriptor(buffer.Address, (ushort)buffer.Size, recvPointerIndex);
|
||||
}
|
||||
else if (flags.HasFlag(HipcBufferFlags.AutoSelect))
|
||||
else
|
||||
{
|
||||
if (!isBufferMapAlias[i])
|
||||
{
|
||||
response.SendStatics[recvPointerIndex] = new HipcStaticDescriptor(buffer.Address, (ushort)buffer.Size, recvPointerIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
response.SendStatics[recvPointerIndex] = new HipcStaticDescriptor(0UL, 0, recvPointerIndex);
|
||||
}
|
||||
response.SendStatics[recvPointerIndex] = new HipcStaticDescriptor(0UL, 0, recvPointerIndex);
|
||||
}
|
||||
|
||||
recvPointerIndex++;
|
||||
}
|
||||
|
||||
recvPointerIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,15 +338,17 @@ namespace Ryujinx.Horizon.Sdk.Sf
|
|||
|
||||
int inObjectIndex = 0;
|
||||
|
||||
for (int i = 0; i < _args.Length; i++)
|
||||
foreach (CommandArg t in _args)
|
||||
{
|
||||
if (_args[i].Type == CommandArgType.InObject)
|
||||
if (t.Type != CommandArgType.InObject)
|
||||
{
|
||||
int index = inObjectIndex++;
|
||||
var inObject = inObjects[index];
|
||||
|
||||
objects[index] = inObject?.ServiceObject;
|
||||
continue;
|
||||
}
|
||||
|
||||
int index = inObjectIndex++;
|
||||
var inObject = inObjects[index];
|
||||
|
||||
objects[index] = inObject?.ServiceObject;
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue