diff --git a/src/ARMeilleure/Translation/IntervalTree.cs b/src/ARMeilleure/Translation/IntervalTree.cs index 2fa431a8b..072016ef7 100644 --- a/src/ARMeilleure/Translation/IntervalTree.cs +++ b/src/ARMeilleure/Translation/IntervalTree.cs @@ -359,10 +359,7 @@ namespace ARMeilleure.Translation IntervalTreeNode tmp = LeftOf(replacementNode) ?? RightOf(replacementNode); - if (tmp != null) - { - tmp.Parent = ParentOf(replacementNode); - } + tmp?.Parent = ParentOf(replacementNode); if (ParentOf(replacementNode) == null) { @@ -570,10 +567,7 @@ namespace ARMeilleure.Translation { IntervalTreeNode right = RightOf(node); node.Right = LeftOf(right); - if (node.Right != null) - { - node.Right.Parent = node; - } + node.Right?.Parent = node; IntervalTreeNode nodeParent = ParentOf(node); right.Parent = nodeParent; if (nodeParent == null) @@ -601,10 +595,7 @@ namespace ARMeilleure.Translation { IntervalTreeNode left = LeftOf(node); node.Left = RightOf(left); - if (node.Left != null) - { - node.Left.Parent = node; - } + node.Left?.Parent = node; IntervalTreeNode nodeParent = ParentOf(node); left.Parent = nodeParent; if (nodeParent == null) @@ -651,10 +642,7 @@ namespace ARMeilleure.Translation /// Color (Boolean) private static void SetColor(IntervalTreeNode node, bool color) { - if (node != null) - { - node.Color = color; - } + node?.Color = color; } /// diff --git a/src/Ryujinx.Common/Collections/IntervalTree.cs b/src/Ryujinx.Common/Collections/IntervalTree.cs index 2aa00b1b0..a93d3f66f 100644 --- a/src/Ryujinx.Common/Collections/IntervalTree.cs +++ b/src/Ryujinx.Common/Collections/IntervalTree.cs @@ -384,10 +384,7 @@ namespace Ryujinx.Common.Collections IntervalTreeNode tmp = LeftOf(replacementNode) ?? RightOf(replacementNode); - if (tmp != null) - { - tmp.Parent = ParentOf(replacementNode); - } + tmp?.Parent = ParentOf(replacementNode); if (ParentOf(replacementNode) == null) { diff --git a/src/Ryujinx.Common/Collections/IntrusiveRedBlackTree.cs b/src/Ryujinx.Common/Collections/IntrusiveRedBlackTree.cs index 91f4380ea..47f5b122b 100644 --- a/src/Ryujinx.Common/Collections/IntrusiveRedBlackTree.cs +++ b/src/Ryujinx.Common/Collections/IntrusiveRedBlackTree.cs @@ -232,10 +232,7 @@ namespace Ryujinx.Common.Collections parent = ParentOf(element); color = ColorOf(element); - if (child != null) - { - child.Parent = parent; - } + child?.Parent = parent; if (parent == null) { @@ -255,8 +252,7 @@ namespace Ryujinx.Common.Collections element.Right = old.Right; element.Parent = old.Parent; element.Predecessor = old.Predecessor; - if (element.Predecessor != null) - element.Predecessor.Successor = element; + element.Predecessor?.Successor = element; if (ParentOf(old) == null) { @@ -289,10 +285,7 @@ namespace Ryujinx.Common.Collections parent = ParentOf(nodeToDelete); color = ColorOf(nodeToDelete); - if (child != null) - { - child.Parent = parent; - } + child?.Parent = parent; if (parent == null) { @@ -311,11 +304,9 @@ namespace Ryujinx.Common.Collections { RestoreBalanceAfterRemoval(child); } - - if (old.Successor != null) - old.Successor.Predecessor = old.Predecessor; - if (old.Predecessor != null) - old.Predecessor.Successor = old.Successor; + + old.Successor?.Predecessor = old.Predecessor; + old.Predecessor?.Successor = old.Successor; return old; } diff --git a/src/Ryujinx.Common/Collections/IntrusiveRedBlackTreeImpl.cs b/src/Ryujinx.Common/Collections/IntrusiveRedBlackTreeImpl.cs index 49f97223a..fb32cec73 100644 --- a/src/Ryujinx.Common/Collections/IntrusiveRedBlackTreeImpl.cs +++ b/src/Ryujinx.Common/Collections/IntrusiveRedBlackTreeImpl.cs @@ -238,10 +238,7 @@ namespace Ryujinx.Common.Collections { T right = RightOf(node); node.Right = LeftOf(right); - if (node.Right != null) - { - node.Right.Parent = node; - } + node.Right?.Parent = node; T nodeParent = ParentOf(node); right.Parent = nodeParent; if (nodeParent == null) @@ -267,10 +264,7 @@ namespace Ryujinx.Common.Collections { T left = LeftOf(node); node.Left = RightOf(left); - if (node.Left != null) - { - node.Left.Parent = node; - } + node.Left?.Parent = node; T nodeParent = ParentOf(node); left.Parent = nodeParent; if (nodeParent == null) @@ -313,10 +307,7 @@ namespace Ryujinx.Common.Collections /// Color (Boolean) protected static void SetColor(T node, bool color) { - if (node != null) - { - node.Color = color; - } + node?.Color = color; } /// diff --git a/src/Ryujinx.Common/Collections/TreeDictionary.cs b/src/Ryujinx.Common/Collections/TreeDictionary.cs index 2a2b0e0b4..79f01ae76 100644 --- a/src/Ryujinx.Common/Collections/TreeDictionary.cs +++ b/src/Ryujinx.Common/Collections/TreeDictionary.cs @@ -318,10 +318,7 @@ namespace Ryujinx.Common.Collections Node tmp = LeftOf(replacementNode) ?? RightOf(replacementNode); - if (tmp != null) - { - tmp.Parent = ParentOf(replacementNode); - } + tmp?.Parent = ParentOf(replacementNode); if (ParentOf(replacementNode) == null) { diff --git a/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs index 2d67c2c28..33381dd55 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs @@ -84,10 +84,7 @@ namespace Ryujinx.Graphics.Gpu.Memory for (int i = 0; i < count; i++) { ICounterEvent evt = _items[index + i].Event; - if (evt != null) - { - evt.Invalid = true; - } + evt?.Invalid = true; } _items.RemoveRange(index, count); diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BranchElimination.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BranchElimination.cs index bd2eceda5..ab988f70e 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BranchElimination.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BranchElimination.cs @@ -26,12 +26,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations // - Both branches are jumping to the same location. // In this case, the branch on the current block can be removed, // as the next block is going to jump to the same place anyway. - if (nextBlock == null) - { - return false; - } - if (nextBlock.Operations.First?.Value is not Operation next) + if (nextBlock?.Operations.First?.Value is not Operation next) { return false; } diff --git a/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs b/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs index 649e36790..d7d8ae488 100644 --- a/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs +++ b/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs @@ -885,10 +885,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler result = new NestedName(name, prev); } - if (context != null) - { - context.FinishWithTemplateArguments = false; - } + context?.FinishWithTemplateArguments = false; return result; } @@ -1068,10 +1065,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler return null; } - if (context != null) - { - context.CtorDtorConversion = true; - } + context?.CtorDtorConversion = true; return new ConversionOperatorType(type); default: @@ -1339,10 +1333,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler _position++; - if (context != null) - { - context.CtorDtorConversion = true; - } + context?.CtorDtorConversion = true; if (isInherited && ParseName(context) == null) { @@ -1362,10 +1353,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler _position++; - if (context != null) - { - context.CtorDtorConversion = true; - } + context?.CtorDtorConversion = true; return new CtorDtorNameType(prev, true); } @@ -2968,16 +2956,10 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler BaseNode result = null; CvType cv = new(ParseCvQualifiers(), null); - if (context != null) - { - context.Cv = cv; - } + context?.Cv = cv; SimpleReferenceType Ref = ParseRefQualifiers(); - if (context != null) - { - context.Ref = Ref; - } + context?.Ref = Ref; if (ConsumeIf("St")) { @@ -3022,10 +3004,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler } result = new NameTypeWithTemplateArguments(result, templateArgument); - if (context != null) - { - context.FinishWithTemplateArguments = true; - } + context?.FinishWithTemplateArguments = true; _substitutionList.Add(result); continue; @@ -3215,10 +3194,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler return null; } - if (context != null) - { - context.FinishWithTemplateArguments = true; - } + context?.FinishWithTemplateArguments = true; return new NameTypeWithTemplateArguments(substitution, templateArguments); } @@ -3238,10 +3214,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler return null; } - if (context != null) - { - context.FinishWithTemplateArguments = true; - } + context?.FinishWithTemplateArguments = true; return new NameTypeWithTemplateArguments(result, templateArguments); } diff --git a/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs b/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs index 9fa05ffc8..71b03efa7 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs @@ -177,10 +177,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading if (previousThread != nextThread) { - if (previousThread != null) - { - previousThread.LastScheduledTime = PerformanceCounter.ElapsedTicks; - } + previousThread?.LastScheduledTime = PerformanceCounter.ElapsedTicks; _state.SelectedThread = nextThread; _state.NeedsScheduling = true; diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index 0f0bb2950..ff6ae66f7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -1169,9 +1169,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public override void DestroyAtExit() { - if (_context != null) { - _context.Dispose(); - } + _context?.Dispose(); } } } diff --git a/src/Ryujinx.Memory/Tracking/SmartMultiRegionHandle.cs b/src/Ryujinx.Memory/Tracking/SmartMultiRegionHandle.cs index 8ea687f79..525d603ea 100644 --- a/src/Ryujinx.Memory/Tracking/SmartMultiRegionHandle.cs +++ b/src/Ryujinx.Memory/Tracking/SmartMultiRegionHandle.cs @@ -58,10 +58,7 @@ namespace Ryujinx.Memory.Tracking { foreach (var handle in _handles) { - if (handle != null) - { - handle?.RegisterAction((_, _) => action(handle.Address, handle.Size)); - } + handle?.RegisterAction((_, _) => action(handle.Address, handle.Size)); } } @@ -69,10 +66,7 @@ namespace Ryujinx.Memory.Tracking { foreach (var handle in _handles) { - if (handle != null) - { - handle?.RegisterPreciseAction((_, _, write) => action(handle.Address, handle.Size, write)); - } + handle?.RegisterPreciseAction((_, _, write) => action(handle.Address, handle.Size, write)); } } diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index 6437d3e12..fa56f8ec1 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -508,18 +508,12 @@ namespace Ryujinx.Ava private void UpdateIgnoreMissingServicesState(object sender, ReactiveEventArgs args) { - if (Device != null) - { - Device.Configuration.IgnoreMissingServices = args.NewValue; - } + Device?.Configuration.IgnoreMissingServices = args.NewValue; } private void UpdateAspectRatioState(object sender, ReactiveEventArgs args) { - if (Device != null) - { - Device.Configuration.AspectRatio = args.NewValue; - } + Device?.Configuration.AspectRatio = args.NewValue; } private void UpdateAntiAliasing(object sender, ReactiveEventArgs e) diff --git a/src/Ryujinx/UI/Applet/SwkbdAppletDialog.axaml.cs b/src/Ryujinx/UI/Applet/SwkbdAppletDialog.axaml.cs index 25e92570f..505d38a43 100644 --- a/src/Ryujinx/UI/Applet/SwkbdAppletDialog.axaml.cs +++ b/src/Ryujinx/UI/Applet/SwkbdAppletDialog.axaml.cs @@ -167,10 +167,7 @@ namespace Ryujinx.Ava.UI.Controls private void Message_TextInput(object sender, TextInputEventArgs e) { - if (_host != null) - { - _host.IsPrimaryButtonEnabled = _checkLength(Message.Length) && _checkInput(Message); - } + _host?.IsPrimaryButtonEnabled = _checkLength(Message.Length) && _checkInput(Message); } private void Message_KeyUp(object sender, KeyEventArgs e)