Use emplace() instead of insert() where applicable for maps.

This commit is contained in:
Lioncash
2015-06-28 19:08:28 -04:00
parent 1120132d26
commit daa205990f
12 changed files with 41 additions and 30 deletions

View File

@ -315,9 +315,11 @@ ID3D11SamplerState* StateCache::Get(SamplerState state)
ID3D11SamplerState* res = nullptr;
HRESULT hr = D3D::device->CreateSamplerState(&sampdc, &res);
if (FAILED(hr)) PanicAlert("Fail %s %d\n", __FILE__, __LINE__);
if (FAILED(hr))
PanicAlert("Fail %s %d\n", __FILE__, __LINE__);
D3D::SetDebugObjectName((ID3D11DeviceChild*)res, "sampler state used to emulate the GX pipeline");
m_sampler.insert(std::make_pair(state.packed, res));
m_sampler.emplace(state.packed, res);
return res;
}
@ -394,9 +396,11 @@ ID3D11BlendState* StateCache::Get(BlendState state)
ID3D11BlendState* res = nullptr;
HRESULT hr = D3D::device->CreateBlendState(&blenddc, &res);
if (FAILED(hr)) PanicAlert("Failed to create blend state at %s %d\n", __FILE__, __LINE__);
if (FAILED(hr))
PanicAlert("Failed to create blend state at %s %d\n", __FILE__, __LINE__);
D3D::SetDebugObjectName((ID3D11DeviceChild*)res, "blend state used to emulate the GX pipeline");
m_blend.insert(std::make_pair(state.packed, res));
m_blend.emplace(state.packed, res);
return res;
}
@ -415,9 +419,11 @@ ID3D11RasterizerState* StateCache::Get(RasterizerState state)
ID3D11RasterizerState* res = nullptr;
HRESULT hr = D3D::device->CreateRasterizerState(&rastdc, &res);
if (FAILED(hr)) PanicAlert("Failed to create rasterizer state at %s %d\n", __FILE__, __LINE__);
if (FAILED(hr))
PanicAlert("Failed to create rasterizer state at %s %d\n", __FILE__, __LINE__);
D3D::SetDebugObjectName((ID3D11DeviceChild*)res, "rasterizer state used to emulate the GX pipeline");
m_raster.insert(std::make_pair(state.packed, res));
m_raster.emplace(state.packed, res);
return res;
}
@ -466,10 +472,12 @@ ID3D11DepthStencilState* StateCache::Get(ZMode state)
ID3D11DepthStencilState* res = nullptr;
HRESULT hr = D3D::device->CreateDepthStencilState(&depthdc, &res);
if (SUCCEEDED(hr)) D3D::SetDebugObjectName((ID3D11DeviceChild*)res, "depth-stencil state used to emulate the GX pipeline");
else PanicAlert("Failed to create depth state at %s %d\n", __FILE__, __LINE__);
if (SUCCEEDED(hr))
D3D::SetDebugObjectName((ID3D11DeviceChild*)res, "depth-stencil state used to emulate the GX pipeline");
else
PanicAlert("Failed to create depth state at %s %d\n", __FILE__, __LINE__);
m_depth.insert(std::make_pair(state.hex, res));
m_depth.emplace(state.hex, res);
return res;
}