From 3b31b9abe2fd89875f64d09ff85b86d7136a5913 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 6 Oct 2023 10:59:05 +0200 Subject: [PATCH] Remove unnecessary NativeMemory.Free branches --- .../Interop/Effects/PixelShaderEffect.cs | 10 ++----- .../D2D1ResourceTextureManagerImpl.cs | 29 ++++--------------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs index 32d6ec72..49f7428b 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs @@ -154,10 +154,7 @@ internal unsafe partial struct PixelShaderEffect catch (Exception) { // Free the effect, if we have one - if (@this is not null) - { - NativeMemory.Free(@this); - } + NativeMemory.Free(@this); // Free the handle, if we have one if (globalsHandle.IsAllocated) @@ -244,10 +241,7 @@ internal unsafe partial struct PixelShaderEffect this.globalsHandle.Free(); } - if (this.constantBuffer is not null) - { - NativeMemory.Free(this.constantBuffer); - } + NativeMemory.Free(this.constantBuffer); if (this.d2D1TransformMapper is not null) { diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs index 575fdcc6..e501fddb 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs @@ -263,30 +263,11 @@ internal unsafe partial struct D2D1ResourceTextureManagerImpl _ = this.d2D1Multithread->Release(); } - if (this.resourceId is not null) - { - NativeMemory.Free(this.resourceId); - } - - if (this.resourceTextureProperties.extents is not null) - { - NativeMemory.Free(this.resourceTextureProperties.extents); - } - - if (this.resourceTextureProperties.extendModes is not null) - { - NativeMemory.Free(this.resourceTextureProperties.extendModes); - } - - if (this.data is not null) - { - NativeMemory.Free(this.data); - } - - if (this.strides is not null) - { - NativeMemory.Free(this.strides); - } + NativeMemory.Free(this.resourceId); + NativeMemory.Free(this.resourceTextureProperties.extents); + NativeMemory.Free(this.resourceTextureProperties.extendModes); + NativeMemory.Free(this.data); + NativeMemory.Free(this.strides); } this.lockHandle.Free();