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:
ACGNnsj 2023-03-28 20:59:43 +08:00 committed by GitHub
parent 7ca779a26d
commit 460f96967d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 106 deletions

View file

@ -37,12 +37,7 @@ namespace Ryujinx.Horizon.Sm.Impl
result = GetServiceImpl(out handle, ref _services[serviceIndex]);
if (result == KernelResult.SessionCountExceeded)
{
return SmResult.OutOfSessions;
}
return result;
return result == KernelResult.SessionCountExceeded ? SmResult.OutOfSessions : result;
}
private Result GetServiceImpl(out int handle, ref ServiceInfo serviceInfo)
@ -61,13 +56,7 @@ namespace Ryujinx.Horizon.Sm.Impl
}
// TODO: Validation with GetProcessInfo etc.
if (HasServiceInfo(name))
{
return SmResult.AlreadyRegistered;
}
return RegisterServiceImpl(out handle, processId, name, maxSessions, isLight);
return HasServiceInfo(name) ? SmResult.AlreadyRegistered : RegisterServiceImpl(out handle, processId, name, maxSessions, isLight);
}
public Result RegisterServiceForSelf(out int handle, ServiceName name, int maxSessions)