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
|
@ -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;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
if (!classDeclaration.AttributeLists.Any(attributeList =>
|
||||
attributeList.Attributes.Any(x => x.Name.GetText().ToString() == "SvcImpl")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue