aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Horizon.Kernel.Generators/Kernel/SyscallSyntaxReceiver.cs
diff options
context:
space:
mode:
authorACGNnsj <ootopoo@vip.qq.com>2023-03-28 20:59:43 +0800
committerGitHub <noreply@github.com>2023-03-28 14:59:43 +0200
commit460f96967de6f5cb729ed57baaa4dad2178c8cb6 (patch)
tree9cb4ef2daa0e712d3b449572ab018e9fdab74179 /Ryujinx.Horizon.Kernel.Generators/Kernel/SyscallSyntaxReceiver.cs
parent7ca779a26d76a3ad1edd94ba6c1cfd7466d73314 (diff)
Slight Code Refactoring (#4373)1.1.687
* 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
Diffstat (limited to 'Ryujinx.Horizon.Kernel.Generators/Kernel/SyscallSyntaxReceiver.cs')
-rw-r--r--Ryujinx.Horizon.Kernel.Generators/Kernel/SyscallSyntaxReceiver.cs45
1 files changed, 22 insertions, 23 deletions
diff --git a/Ryujinx.Horizon.Kernel.Generators/Kernel/SyscallSyntaxReceiver.cs b/Ryujinx.Horizon.Kernel.Generators/Kernel/SyscallSyntaxReceiver.cs
index e2e8e1d3..e480a859 100644
--- a/Ryujinx.Horizon.Kernel.Generators/Kernel/SyscallSyntaxReceiver.cs
+++ b/Ryujinx.Horizon.Kernel.Generators/Kernel/SyscallSyntaxReceiver.cs
@@ -16,38 +16,37 @@ namespace Ryujinx.Horizon.Generators.Kernel
public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
{
- if (syntaxNode is ClassDeclarationSyntax classDeclaration && classDeclaration.AttributeLists.Count != 0)
+ if (!(syntaxNode is ClassDeclarationSyntax classDeclaration) || classDeclaration.AttributeLists.Count == 0)
{
- foreach (var attributeList in classDeclaration.AttributeLists)
- {
- if (attributeList.Attributes.Any(x => x.Name.GetText().ToString() == "SvcImpl"))
- {
- foreach (var memberDeclaration in classDeclaration.Members)
- {
- if (memberDeclaration is MethodDeclarationSyntax methodDeclaration)
- {
- VisitMethod(methodDeclaration);
- }
- }
+ return;
+ }
+
+ if (!classDeclaration.AttributeLists.Any(attributeList =>
+ attributeList.Attributes.Any(x => x.Name.GetText().ToString() == "SvcImpl")))
+ {
+ return;
+ }
- break;
- }
+ foreach (var memberDeclaration in classDeclaration.Members)
+ {
+ if (memberDeclaration is MethodDeclarationSyntax methodDeclaration)
+ {
+ VisitMethod(methodDeclaration);
}
}
}
private void VisitMethod(MethodDeclarationSyntax methodDeclaration)
{
- if (methodDeclaration.AttributeLists.Count != 0)
+ if (methodDeclaration.AttributeLists.Count == 0)
{
- foreach (var attributeList in methodDeclaration.AttributeLists)
- {
- if (attributeList.Attributes.Any(x => x.Name.GetText().ToString() == "Svc"))
- {
- SvcImplementations.Add(methodDeclaration);
- break;
- }
- }
+ return;
+ }
+
+ if (methodDeclaration.AttributeLists.Any(attributeList =>
+ attributeList.Attributes.Any(x => x.Name.GetText().ToString() == "Svc")))
+ {
+ SvcImplementations.Add(methodDeclaration);
}
}
}