From 742083ae3d3f5d27e9a106e39ea8951bf82f4f73 Mon Sep 17 00:00:00 2001
From: Evan Husted <greem@greemdev.net>
Date: Sun, 26 Jan 2025 15:19:33 -0600
Subject: [PATCH] misc: chore: Fix object creation in Horizon

---
 src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator.cs                | 4 ++--
 .../Bcat/Ipc/ServiceCreator/DeliveryCacheStorageService.cs    | 4 ++--
 src/Ryujinx.Horizon/HeapAllocator.cs                          | 4 ++--
 src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRenderer.cs         | 2 +-
 src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRendererManager.cs  | 4 ++--
 src/Ryujinx.Horizon/Sdk/Lbl/LblApi.cs                         | 2 +-
 .../Sdk/Sf/Cmif/DomainServiceObjectDispatchTable.cs           | 2 +-
 src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServerDomainManager.cs        | 2 +-
 src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerSessionManager.cs       | 4 ++--
 9 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator.cs b/src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator.cs
index 6984d69c4..35967d274 100644
--- a/src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator.cs
+++ b/src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator.cs
@@ -39,7 +39,7 @@ namespace Ryujinx.Horizon.Bcat.Ipc
         [CmifCommand(1)]
         public Result CreateDeliveryCacheStorageService(out IDeliveryCacheStorageService service, [ClientProcessId] ulong pid)
         {
-            using SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
+            using SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> libHacService = new();
 
             LibHac.Result resultCode = _libHacService.Get.CreateDeliveryCacheStorageService(ref libHacService.Ref, pid);
 
@@ -58,7 +58,7 @@ namespace Ryujinx.Horizon.Bcat.Ipc
         [CmifCommand(2)]
         public Result CreateDeliveryCacheStorageServiceWithApplicationId(out IDeliveryCacheStorageService service, ApplicationId applicationId)
         {
-            using SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
+            using SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> libHacService = new();
 
             LibHac.Result resultCode = _libHacService.Get.CreateDeliveryCacheStorageServiceWithApplicationId(ref libHacService.Ref, new LibHac.ApplicationId(applicationId.Id));
 
diff --git a/src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator/DeliveryCacheStorageService.cs b/src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator/DeliveryCacheStorageService.cs
index 4142c14f8..356156fc1 100644
--- a/src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator/DeliveryCacheStorageService.cs
+++ b/src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator/DeliveryCacheStorageService.cs
@@ -22,7 +22,7 @@ namespace Ryujinx.Horizon.Bcat.Ipc
         [CmifCommand(0)]
         public Result CreateFileService(out IDeliveryCacheFileService service)
         {
-            using SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>();
+            using SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> libHacService = new();
 
             LibHac.Result resultCode = _libHacService.Get.CreateFileService(ref libHacService.Ref);
 
@@ -41,7 +41,7 @@ namespace Ryujinx.Horizon.Bcat.Ipc
         [CmifCommand(1)]
         public Result CreateDirectoryService(out IDeliveryCacheDirectoryService service)
         {
-            using SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>();
+            using SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> libHacService = new();
 
             LibHac.Result resultCode = _libHacService.Get.CreateDirectoryService(ref libHacService.Ref);
 
diff --git a/src/Ryujinx.Horizon/HeapAllocator.cs b/src/Ryujinx.Horizon/HeapAllocator.cs
index 838e505d3..764f00a2f 100644
--- a/src/Ryujinx.Horizon/HeapAllocator.cs
+++ b/src/Ryujinx.Horizon/HeapAllocator.cs
@@ -103,7 +103,7 @@ namespace Ryujinx.Horizon
 
         private void InsertFreeRange(ulong offset, ulong size)
         {
-            Range range = new Range(offset, size);
+            Range range = new(offset, size);
             int index = _freeRanges.BinarySearch(range);
             if (index < 0)
             {
@@ -116,7 +116,7 @@ namespace Ryujinx.Horizon
         private void InsertFreeRangeComingled(ulong offset, ulong size)
         {
             ulong endOffset = offset + size;
-            Range range = new Range(offset, size);
+            Range range = new(offset, size);
             int index = _freeRanges.BinarySearch(range);
             if (index < 0)
             {
diff --git a/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRenderer.cs b/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRenderer.cs
index 4d446bba7..168d58619 100644
--- a/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRenderer.cs
+++ b/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRenderer.cs
@@ -64,7 +64,7 @@ namespace Ryujinx.Horizon.Sdk.Audio.Detail
             using MemoryHandle outputHandle = output.Pin();
             using MemoryHandle performanceOutputHandle = performanceOutput.Pin();
 
-            Result result = new Result((int)_renderSystem.Update(output, performanceOutput, input));
+            Result result = new((int)_renderSystem.Update(output, performanceOutput, input));
 
             return result;
         }
diff --git a/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRendererManager.cs b/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRendererManager.cs
index c1c7453a1..40cbecc40 100644
--- a/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRendererManager.cs
+++ b/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRendererManager.cs
@@ -34,7 +34,7 @@ namespace Ryujinx.Horizon.Sdk.Audio.Detail
             IVirtualMemoryManager clientMemoryManager = HorizonStatic.Syscall.GetMemoryManagerByProcessHandle(processHandle);
             ulong workBufferAddress = HorizonStatic.Syscall.GetTransferMemoryAddress(workBufferHandle);
 
-            Result result = new Result((int)_impl.OpenAudioRenderer(
+            Result result = new((int)_impl.OpenAudioRenderer(
                 out AudioRenderSystem renderSystem,
                 clientMemoryManager,
                 ref parameter.Configuration,
@@ -99,7 +99,7 @@ namespace Ryujinx.Horizon.Sdk.Audio.Detail
         {
             IVirtualMemoryManager clientMemoryManager = HorizonStatic.Syscall.GetMemoryManagerByProcessHandle(processHandle);
 
-            Result result = new Result((int)_impl.OpenAudioRenderer(
+            Result result = new((int)_impl.OpenAudioRenderer(
                 out AudioRenderSystem renderSystem,
                 clientMemoryManager,
                 ref parameter.Configuration,
diff --git a/src/Ryujinx.Horizon/Sdk/Lbl/LblApi.cs b/src/Ryujinx.Horizon/Sdk/Lbl/LblApi.cs
index ef42d777f..e55dd75be 100644
--- a/src/Ryujinx.Horizon/Sdk/Lbl/LblApi.cs
+++ b/src/Ryujinx.Horizon/Sdk/Lbl/LblApi.cs
@@ -12,7 +12,7 @@ namespace Ryujinx.Horizon.Sdk.Lbl
 
         public LblApi()
         {
-            using SmApi smApi = new SmApi();
+            using SmApi smApi = new();
 
             smApi.Initialize();
             smApi.GetServiceHandle(out _sessionHandle, ServiceName.Encode(LblName)).AbortOnFailure();
diff --git a/src/Ryujinx.Horizon/Sdk/Sf/Cmif/DomainServiceObjectDispatchTable.cs b/src/Ryujinx.Horizon/Sdk/Sf/Cmif/DomainServiceObjectDispatchTable.cs
index 1a14164c3..2e7879f2d 100644
--- a/src/Ryujinx.Horizon/Sdk/Sf/Cmif/DomainServiceObjectDispatchTable.cs
+++ b/src/Ryujinx.Horizon/Sdk/Sf/Cmif/DomainServiceObjectDispatchTable.cs
@@ -48,7 +48,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
 
                     int[] inObjectIds = new int[inHeader.ObjectsCount];
 
-                    DomainServiceObjectProcessor domainProcessor = new DomainServiceObjectProcessor(domain, inObjectIds);
+                    DomainServiceObjectProcessor domainProcessor = new(domain, inObjectIds);
 
                     if (context.Processor == null)
                     {
diff --git a/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServerDomainManager.cs b/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServerDomainManager.cs
index ae909c9b7..631f2360a 100644
--- a/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServerDomainManager.cs
+++ b/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServerDomainManager.cs
@@ -230,7 +230,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif
                     return null;
                 }
 
-                Domain domain = new Domain(this);
+                Domain domain = new(this);
                 _domains.Add(domain);
                 return domain;
             }
diff --git a/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerSessionManager.cs b/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerSessionManager.cs
index f902768cc..f51e0811e 100644
--- a/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerSessionManager.cs
+++ b/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerSessionManager.cs
@@ -186,7 +186,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
         {
             CommandType commandType = GetCmifCommandType(inMessage);
 
-            using ScopedInlineContextChange _ = new ScopedInlineContextChange(GetInlineContext(commandType, inMessage));
+            using ScopedInlineContextChange _ = new(GetInlineContext(commandType, inMessage));
 
             return commandType switch
             {
@@ -282,7 +282,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
                 return HipcResult.InvalidRequestSize;
             }
 
-            ServiceDispatchContext dispatchCtx = new ServiceDispatchContext
+            ServiceDispatchContext dispatchCtx = new()
             {
                 ServiceObject = objectHolder.ServiceObject,
                 Manager = this,