浏览代码

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 年之前
父节点
当前提交
13cfd95fef
共有 1 个文件被更改,包括 10 次插入2 次删除
  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);
 }