Browse Source

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.
Richard Stanway 4 năm trước cách đây
mục cha
commit
13cfd95fef
1 tập tin đã thay đổi với 10 bổ sung2 xóa
  1. 10 2
      libobs-d3d11/d3d11-subsystem.cpp

+ 10 - 2
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);
 }