From 13cfd95fef7367b62baadf5e21c140f27cb51cbe Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Thu, 4 Mar 2021 17:57:41 +0100 Subject: [PATCH] libobs-d3d11: Avoid temporary ComPtr objects The ternary operator promotes both sides to the same type if possible, so it created and destroyed a temporary ComPtr. Found by PVS Studio. --- libobs-d3d11/d3d11-subsystem.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index bc9898758..ce47e730f 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -1468,13 +1468,21 @@ static void device_load_texture_internal(gs_device_t *device, gs_texture_t *tex, void device_load_texture(gs_device_t *device, gs_texture_t *tex, int unit) { - ID3D11ShaderResourceView *view = tex ? tex->shaderRes : NULL; + ID3D11ShaderResourceView *view; + if (tex) + view = tex->shaderRes; + else + view = NULL; return device_load_texture_internal(device, tex, unit, view); } void device_load_texture_srgb(gs_device_t *device, gs_texture_t *tex, int unit) { - ID3D11ShaderResourceView *view = tex ? tex->shaderResLinear : NULL; + ID3D11ShaderResourceView *view; + if (tex) + view = tex->shaderResLinear; + else + view = NULL; return device_load_texture_internal(device, tex, unit, view); }