Turn loops into range-based form

and some things suggested by cppcheck and compiler warnings.
This commit is contained in:
Tillmann Karras
2014-02-12 16:00:34 +01:00
parent 2ff794d299
commit 404624bf0b
52 changed files with 199 additions and 230 deletions

View File

@ -41,8 +41,8 @@ public:
offset = 0;
context->Map(buf, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
for(std::list<bool*>::iterator it = observers.begin(); it != observers.end(); ++it)
**it = true;
for(bool* observer : observers)
*observer = true;
}
else
{

View File

@ -149,9 +149,9 @@ void LineGeometryShader::Shutdown()
{
m_ready = false;
for (ComboMap::iterator it = m_shaders.begin(); it != m_shaders.end(); ++it)
for (auto& it : m_shaders)
{
SAFE_RELEASE(it->second);
SAFE_RELEASE(it.second);
}
m_shaders.clear();

View File

@ -1012,10 +1012,9 @@ void PSTextureEncoder::Shutdown()
SAFE_RELEASE(m_classLinkage);
SAFE_RELEASE(m_dynamicShader);
for (ComboMap::iterator it = m_staticShaders.begin();
it != m_staticShaders.end(); ++it)
for (auto& it : m_staticShaders)
{
SAFE_RELEASE(it->second);
SAFE_RELEASE(it.second);
}
m_staticShaders.clear();

View File

@ -410,8 +410,8 @@ void PixelShaderCache::Init()
// ONLY to be used during shutdown.
void PixelShaderCache::Clear()
{
for (PSCache::iterator iter = PixelShaders.begin(); iter != PixelShaders.end(); iter++)
iter->second.Destroy();
for (auto& iter : PixelShaders)
iter.second.Destroy();
PixelShaders.clear();
pixel_uid_checker.Invalidate();

View File

@ -143,9 +143,9 @@ void PointGeometryShader::Shutdown()
{
m_ready = false;
for (ComboMap::iterator it = m_shaders.begin(); it != m_shaders.end(); ++it)
for (auto& it : m_shaders)
{
SAFE_RELEASE(it->second);
SAFE_RELEASE(it.second);
}
m_shaders.clear();

View File

@ -157,8 +157,8 @@ void VertexShaderCache::Init()
void VertexShaderCache::Clear()
{
for (VSCache::iterator iter = vshaders.begin(); iter != vshaders.end(); ++iter)
iter->second.Destroy();
for (auto& iter : vshaders)
iter.second.Destroy();
vshaders.clear();
vertex_uid_checker.Invalidate();

View File

@ -710,15 +710,14 @@ void Renderer::DrawDebugInfo()
int a = 0;
GLfloat color[3] = {0.0f, 1.0f, 1.0f};
for (std::vector<EFBRectangle>::const_iterator it = stats.efb_regions.begin();
it != stats.efb_regions.end(); ++it)
for (const EFBRectangle& rect : stats.efb_regions)
{
GLfloat halfWidth = EFB_WIDTH / 2.0f;
GLfloat halfHeight = EFB_HEIGHT / 2.0f;
GLfloat x = (GLfloat) -1.0f + ((GLfloat)it->left / halfWidth);
GLfloat y = (GLfloat) 1.0f - ((GLfloat)it->top / halfHeight);
GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)it->right / halfWidth);
GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)it->bottom / halfHeight);
GLfloat x = (GLfloat) -1.0f + ((GLfloat)rect.left / halfWidth);
GLfloat y = (GLfloat) 1.0f - ((GLfloat)rect.top / halfHeight);
GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)rect.right / halfWidth);
GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)rect.bottom / halfHeight);
Vertices[a++] = x;
Vertices[a++] = y;
@ -1782,7 +1781,7 @@ void Renderer::FlipImageData(u8 *data, int w, int h, int pixel_width)
{
for(int x = 0; x < w; ++x)
{
for (auto delta = 0; delta < pixel_width; ++delta)
for (int delta = 0; delta < pixel_width; ++delta)
std::swap(data[(y * w + x) * pixel_width + delta], data[((h - 1 - y) * w + x) * pixel_width + delta]);
}
}